Skip to content

[emacs] More consistently highlight value keywords that appear in vectors #97594

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion llvm/utils/emacs/llvm-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
`(,(concat "\\<" llvm-mode-primitive-type-regexp "\\>") . font-lock-type-face)
;; Integer literals
'("\\b[-]?[0-9]+\\b" . font-lock-preprocessor-face)
;; Values that can appear in a vec
'("\\b\\(true\\|false\\|null\\|undef\\|poison\\|none\\)\\b" . font-lock-keyword-face)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the 'words paren argument to regexp-opt would also work? https://www.gnu.org/software/emacs/manual/html_node/elisp/Regexp-Functions.html#index-regexp_002dopt

`(,(regexp-opt '("true" "false" "null" "undef" "none" "poison") 'words) . font-lock-keyword-face

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me check.

BTW, first I tried (mapconcat 'identity '("true" "false" "null" "undef" "none" "poison") "//|") for the list but that didn't work, any idea why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem to work.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW, first I tried (mapconcat 'identity '("true" "false" "null" "undef" "none" "poison") "//|") for the list but that didn't work, any idea why?

Did you mean \\|?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't seem to work.

Ah well, was worth a shot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Full code:

'((concat "\\b\\(" (mapconcat 'identity '("true" "false" "null" "undef" "none" "poison") "\\|") "\\)\\b") . font-lock-keyword-face)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also LGTM!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Err that doesn't work, any idea why?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No idea. Evaluating your snippet gives me "\\b\\(true\\|false\\|null\\|undef\\|none\\|poison\\)\\b" which is the same as whats in this PR, but none and poison are swapped around?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I don't know either, cest la vie, ill merge this as is.

;; Floating point constants
'("\\b[-+]?[0-9]+.[0-9]*\\([eE][-+]?[0-9]+\\)?\\b" . font-lock-preprocessor-face)
;; Hex constants
Expand All @@ -74,7 +76,7 @@
"private" "internal" "weak" "weak_odr" "linkonce" "linkonce_odr" "available_externally" "appending" "common" "extern_weak" "external"
"uninitialized" "implementation" "..."
;; Values
"true" "false" "null" "undef" "zeroinitializer" "none" "c" "asm" "blockaddress" "poison"
"zeroinitializer" "c" "asm" "blockaddress"

;; Calling conventions
"ccc" "fastcc" "coldcc" "anyregcc" "preserve_mostcc" "preserve_allcc"
Expand Down
Loading