-
Notifications
You must be signed in to change notification settings - Fork 93
Customizable face for numbers #459
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
Customizable face for numbers #459
Conversation
b563cda
to
cb58953
Compare
cb58953
to
ce66d67
Compare
I changed up the test matrix as it was failing on Emacs 24.5 (same with master). Looking around at other major modes, most have moved up to a minimum support of Emacs 26.3, so I did the same. I wanted to test Emacs 27.1 and Emacs 28.0.50, but EVM lacks support for these releases at the moment. |
@Trevoke and @victorolinasc I rolled back all the attempted CI fixes. Please take a look when you get the time 👍 |
(numbers . ,(rx (and symbol-start | ||
(? "-") | ||
(+ digit) | ||
(0+ (and "_" (= 3 digit))) | ||
symbol-end))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too naive for parsing numbers in Elixir. I propose the following:
(numbers . ,(rx (and symbol-start | |
(? "-") | |
(+ digit) | |
(0+ (and "_" (= 3 digit))) | |
symbol-end))) | |
(numbers . ,(rx (and symbol-start | |
(zero-or-one "-") | |
(one-or-more digit) | |
(zero-or-more (or digit (seq ?_ digit))) | |
(zero-or-one ".") | |
(zero-or-more (or digit (seq ?_ digit))) | |
symbol-end))) |
This will match things like:
0
-0
0_0
-0_0.0_0
I know they are not what the formatter will typically do but I see no reason why we should bind this face to only what the formatter does.
Not sure how this will behave inside comments, heredocs and so on though.
Also I am trying to follow the use of zero-or-more
and friends because of what the rest of the file is using.
Tests would be good here too if possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you prefer that, that's fine. I'll leave it your capable hands to get this across the finish line 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this has some good changes (and I really like the documentation improvements for variables).
I think any future work to more flexibly support more number formats can be made as a followup PR.
Background
I had made a patch to doom-emacs (see doomemacs/doomemacs#3613) to highlight
10_000
correctly after the Elixir formatter had run. As a next step, I wanted to have this functionality built into emacs-elixir mode for those who want to customize how numbers show up.While I was in there, I did some general cleanup based on best practices and the Emacs Lisp docs.
Changes
2.4.0
elixir
group rather thanfont-lock-faces
elixir-numbers-face
default
so it does not conflict with today's functionalityelixir-format
variables under the sameelixir
group.lexical-binding: t
to top of the file (from style guide)Discussion
Is
default
appropriate?