-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Use native line numbers in Emacs 26 #10675
Conversation
Is there any way to keep the same state transitions in native line numbers as in nlinum? |
Also, awesome work and thank you. |
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'll test this out today. Thanks again!
@@ -17,14 +17,16 @@ | |||
(conf-mode :location built-in) | |||
(dired :location built-in) | |||
(dired-x :location built-in) | |||
(display-line-numbers :location built-in | |||
:toggle (version<= "26" emacs-version)) |
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.
Is display-line-numbers
stable in versions < 26.1?
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.
Doesn't really matter. The first 26.x release will be 26.1, and the development process already reached RC1 whereemacs-version
says "26.1". Any Emacs build that calls itself version 26.0.x is old and irrelevant by now.
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.
Ok. I just want to make sure that if someone decided to use some version 26.0.x in the future for any reason it wouldn’t break for them.
So far it looks good. I was able to use relative numbers in a large file with no problem. Tested on GUI and daemon (frame and terminal). Both look good. Some feedback:
|
I added `DO NOT MERGE` label while @bmag is still working on it.
bmag <notifications@github.com> writes:
… Note to other maintainers: don't merge this yet, I might need to make a few more changes
Emacs 26.1 will introduce a new minor mode for native line numbers: `display-line-numbers-mode`. It is meant to replace linum and friends (including linum-relative). This PR causes Spacemacs to use `display-line-numbers-mode` in Emacs 26, and `linum-mode` in Emacs 25. If `nlinum` layer is enabled by the user, then `nlinum-mode` will be used instead of `display-line-numbers-mode`. Users of `nlinum` layer are recommended to use `display-line-numbers-mode` in Emacs 26.
There's a small issue that `display-line-numbers-type` is a "global" variable (not buffer-local), so toggling between absolute and relative line numbers in one buffer may affect other buffers. If you test this PR and want to comment about how it behaves, please do.
Currently, the `SPC t n` and `SPC t r` toggles for the three different line numbers solutions behave differently. I'm not sure which behavior is the best, so I'd like to hear what other people prefer. The different behaviors are as follows:
(this summary shows state transitions for line numbers status. "off" means no line numbers are shown, "absolute" means absolute line numbers are shown, "relative" means relative line numbers are shown)
linum:
- `SPC t n`: (state before key press --> state after key press)
- off (variant 1) --> absolute
- off (variant 2) --> relative
- absolute --> off (variant 1)
- relative --> off (variant 2)
- `SPC t r`:
- off (variant 1) --> relative
- off (variant 2) --> off (variant 1)
- absolute --> relative
- relative --> off (variant 1)
nlinum:
- `SPC t n`:
- off (variant 1) --> absolute
- off (variant 2) --> relative
- absolute --> off (variant 1)
- relative --> off (variant 2)
- `SPC t r`:
- off (variant 1) --> off (variant 2)
- off (variant 2) --> off (variant 1)
- absolute --> relative
- relative --> absolute
display-line-numbers:
- `SPC t n`:
- off --> absolute
- absolute --> off
- relative --> absolute
- SPC t r:
- off --> relative
- absolute --> relative
- relative --> off
You can view, comment on, or merge this pull request online at:
#10675
-- Commit Summary --
* define-toggle: add option for custom off-message
* Add support for native line numbers in Emacs 26
-- File Changes --
M core/core-toggle.el (6)
M layers/+misc/nlinum/README.org (8)
M layers/+misc/nlinum/packages.el (6)
M layers/+spacemacs/spacemacs-defaults/README.org (3)
M layers/+spacemacs/spacemacs-defaults/funcs.el (7)
M layers/+spacemacs/spacemacs-defaults/packages.el (48)
M layers/+spacemacs/spacemacs-evil/README.org (2)
M layers/+spacemacs/spacemacs-evil/packages.el (7)
-- Patch Links --
https://github.com/syl20bnr/spacemacs/pull/10675.patch
https://github.com/syl20bnr/spacemacs/pull/10675.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#10675
|
```
display-line-numbers:
- `SPC t n`:
- off --> absolute
- absolute --> off
- relative --> absolute
- SPC t r:
- off --> relative
- absolute --> relative
- relative --> off
```
This seems the most natural and as it should be since beginning.
I'm not fond of the current toggle behavior in develop, does not feel POLA.
Users of `nlinum` layer are recommended to use `display-line-numbers-mode` in Emacs 26.
Let's deprecate it for Emacs 26+ users, there is no point in using it
right ?
bmag <notifications@github.com> writes:
… Note to other maintainers: don't merge this yet, I might need to make a few more changes
Emacs 26.1 will introduce a new minor mode for native line numbers: `display-line-numbers-mode`. It is meant to replace linum and friends (including linum-relative). This PR causes Spacemacs to use `display-line-numbers-mode` in Emacs 26, and `linum-mode` in Emacs 25. If `nlinum` layer is enabled by the user, then `nlinum-mode` will be used instead of `display-line-numbers-mode`. Users of `nlinum` layer are recommended to use `display-line-numbers-mode` in Emacs 26.
There's a small issue that `display-line-numbers-type` is a "global" variable (not buffer-local), so toggling between absolute and relative line numbers in one buffer may affect other buffers. If you test this PR and want to comment about how it behaves, please do.
Currently, the `SPC t n` and `SPC t r` toggles for the three different line numbers solutions behave differently. I'm not sure which behavior is the best, so I'd like to hear what other people prefer. The different behaviors are as follows:
(this summary shows state transitions for line numbers status. "off" means no line numbers are shown, "absolute" means absolute line numbers are shown, "relative" means relative line numbers are shown)
linum:
- `SPC t n`: (state before key press --> state after key press)
- off (variant 1) --> absolute
- off (variant 2) --> relative
- absolute --> off (variant 1)
- relative --> off (variant 2)
- `SPC t r`:
- off (variant 1) --> relative
- off (variant 2) --> off (variant 1)
- absolute --> relative
- relative --> off (variant 1)
nlinum:
- `SPC t n`:
- off (variant 1) --> absolute
- off (variant 2) --> relative
- absolute --> off (variant 1)
- relative --> off (variant 2)
- `SPC t r`:
- off (variant 1) --> off (variant 2)
- off (variant 2) --> off (variant 1)
- absolute --> relative
- relative --> absolute
display-line-numbers:
- `SPC t n`:
- off --> absolute
- absolute --> off
- relative --> absolute
- SPC t r:
- off --> relative
- absolute --> relative
- relative --> off
You can view, comment on, or merge this pull request online at:
#10675
-- Commit Summary --
* define-toggle: add option for custom off-message
* Add support for native line numbers in Emacs 26
-- File Changes --
M core/core-toggle.el (6)
M layers/+misc/nlinum/README.org (8)
M layers/+misc/nlinum/packages.el (6)
M layers/+spacemacs/spacemacs-defaults/README.org (3)
M layers/+spacemacs/spacemacs-defaults/funcs.el (7)
M layers/+spacemacs/spacemacs-defaults/packages.el (48)
M layers/+spacemacs/spacemacs-evil/README.org (2)
M layers/+spacemacs/spacemacs-evil/packages.el (7)
-- Patch Links --
https://github.com/syl20bnr/spacemacs/pull/10675.patch
https://github.com/syl20bnr/spacemacs/pull/10675.diff
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
#10675
|
And let's make the relative toggle key binding be |
Aww man! I liked |
Because we have a bug: setting By the way, turns out
You sure about it? I didn't deprecate the layer because it is opt-in, but I'm ok with deprecating it if you're sure. |
@bmag you called me ? So excited about this PR, learning at the same time the existence of native line numers in Emacs 26 and that Spacemacs will integrate them 😺 |
If it does not bring any benefit for Emacs 26 users, there is no need to
make it available post Emacs 26.
Should be still usable for users with Emacs 25 though.
bmag <notifications@github.com> writes:
…> Some modes that don't normally have line numbers have line numbers (Magit, in particular).
Because we have a bug: setting `dotspacemacs-line-numbers` to `t` or `relative` enables them in all modes, instead of only in `prog-mode` and `text-mode` derivatives (as the documentation claims). I have a fix for it that I will push later.
By the way, turns out `magit-mode` itself disables `linum-mode` and `nlinum-mode` in Magit buffers. If it didn't do that, the same bug would happen with linum-mode as well.
>> Users of `nlinum` layer are recommended to use `display-line-numbers-mode` in Emacs 26.
> Let's deprecate it for Emacs 26+ users
You sure about it? I didn't deprecate the layer because it is opt-in, but I'm ok with deprecating it if you're sure.
--
You are receiving this because you commented.
Reply to this email directly or view it on GitHub:
#10675 (comment)
|
I'm testing this in my spacemacs config with Emacs 26.1rc1 and so far it works great, thank you @bmag! |
I also see them enabled briefly during startup, and after a short while they are disabled (before startup finishes). Don't know why yet. Not sure what you meant about line wrap, though, isn't it normal (except the line numbers)? |
@bmag yes, after a short while they are disabled again for me as well. I mean that while the line numbers are visible, the "emacs)" part of "(spacemacs)" in the top right wraps, as visible in the screenshot. This seems to be a result of the right-aligning not respecting the width of the line numbers? |
@kommen ok, now I see it. The native line numbers use their own new margin-like space, maybe the home buffer's code doesn't respect that. Anyway, I pushed a fix for it now, thanks. |
@bmag thanks, also fixes it for me. |
Emacs 26.1 will introduce a new native line numbers feature: "display-line-numbers". It includes relative line numbers, is faster than current linum-mode, and doesn't use the margin area (it has its own area). So yeah, we want to use the new feature when possible. No changes are required on the user side, except for Emacs 26 users are recommended to remove nlinum layer from their configuration (if they have enabled it). With this change: - Emacs 26: - uses display-line-numbers by default. - linum and linum-relative packages are excluded. - Emacs 25: - does NOT use display-line-numbers. - continues to use linum and linum-relative. - nlinum layer: - can still be used as before in Emacs 25. - is NOT recommended in Emacs 26, but can be used. - when enabled, excludes display-line-numbers.
Fixes a bug where setting `dostpacemacs-line-numbers` to `t` or `relative` enabled line numbers in every buffer, instead of only in buffers that derive from prog-mode and text-mode. Likewise fixes a bug where specifying `:enabled-for-modes nil` (or not specifying `:enabled-for-modes` at all) in `dotspacemacs-line-numbers` settings meant "enable in all modes" instead of "enable in modes derived from prog-mode or text-mode". Also adds a way for users to enable line numbers in *all* buffers.
All our current checks should be enough to enable line numbers only where it makes sense. Disabling in all special buffers is not necessary.
5e802f5
to
8fb0213
Compare
Rebased and cherry picked into develop. I kept the toggles as described in my initial post, since the majority (including me) seems to prefer it that way. Also removed the check for special buffers, since I'm pretty sure we don't need it anymore. After pushing the update I see I forgot to deprecate nlinum for Emacs 26 users. @syl20bnr how do we deprecate an entire layer? Change |
wow, this is fast !!! |
@bmag There is no support for this in the layer system, I just put a dirty
conditional block in
8660f93de :-)
bmag <notifications@github.com> writes:
… Rebased and cherry picked into develop.
I kept the toggles as described in my initial post, since the majority (including me) seems to prefer it that way. Also removed the check for special buffers, since I'm pretty sure we don't need it anymore.
After pushing the update I see I forgot to deprecate nlinum for Emacs 26 users. @syl20bnr how do we deprecate an entire layer? Change `nlinum-packages` so it is empty when Emacs 26 is detected? Also issue a warning?
--
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub:
#10675 (comment)
|
Note to other maintainers: don't merge this yet, I might need to make a few more changes
Emacs 26.1 will introduce a new minor mode for native line numbers:
display-line-numbers-mode
. It is meant to replace linum and friends (including linum-relative). This PR causes Spacemacs to usedisplay-line-numbers-mode
in Emacs 26, andlinum-mode
in Emacs 25. Ifnlinum
layer is enabled by the user, thennlinum-mode
will be used instead ofdisplay-line-numbers-mode
. Users ofnlinum
layer are recommended to usedisplay-line-numbers-mode
in Emacs 26.There's a small issue that
display-line-numbers-type
is a "global" variable (not buffer-local), so toggling between absolute and relative line numbers in one buffer may affect other buffers. If you test this PR and want to comment about how it behaves, please do.Currently, the
SPC t n
andSPC t r
toggles for the three different line numbers solutions behave differently. I'm not sure which behavior is the best, so I'd like to hear what other people prefer. The different behaviors are as follows:(this summary shows state transitions for line numbers status. "off" means no line numbers are shown, "absolute" means absolute line numbers are shown, "relative" means relative line numbers are shown)
linum:
SPC t n
: (state before key press --> state after key press)SPC t r
:nlinum:
SPC t n
:SPC t r
:display-line-numbers:
SPC t n
: