all repos — nixfiles @ 8f91452e14f986669aef418cbcebacc790b863af

System and user configuration, managed by nix and home-manager

Emacs: only toggle relative/absolute line numbers when any are shown
Alan Pearce alan@alanpearce.eu
Sun, 09 Jul 2023 12:30:17 +0200
commit

8f91452e14f986669aef418cbcebacc790b863af

parent

722afe1c779ca56d776b1ce346a1541582838a09

1 files changed, 4 insertions(+), 2 deletions(-)

jump to
M user/emacs/init.eluser/emacs/init.el
@@ -128,11 +128,13 @@ (setq frame-resize-pixelwise t) 
 (defun noct-relative ()
   "Show relative line numbers."
-  (setq-local display-line-numbers 'relative))
+  (when display-line-numbers
+    (setq-local display-line-numbers 'relative)))
 
 (defun noct-absolute ()
   "Show absolute line numbers."
-  (setq-local display-line-numbers t))
+  (when display-line-numbers
+    (setq-local display-line-numbers t)))
 
 (add-hook 'evil-insert-state-entry-hook #'noct-absolute)
 (add-hook 'evil-insert-state-exit-hook #'noct-relative)