From 0cde170eaca10734fce9cb8495b72d4387ae487e Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 18 Mar 2017 11:44:04 -0700 Subject: [PATCH] [Emacs] Use nlinum-mode --- dotfiles/emacs.d/README.org | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/dotfiles/emacs.d/README.org b/dotfiles/emacs.d/README.org index 1a807e49..19242bb5 100644 --- a/dotfiles/emacs.d/README.org +++ b/dotfiles/emacs.d/README.org @@ -998,6 +998,7 @@ This was stolen from https://github.com/jwiegley/dot-emacs (,mode-name ,disable-value))) (imalison:disable-mode-hook linum-mode) +(imalison:disable-mode-hook nlinum-mode) (imalison:disable-mode-hook yas-minor-mode) #+END_SRC ** Other @@ -1141,12 +1142,27 @@ I keep it around just in case I need it. (line-number-mode t) (column-number-mode t) #+END_SRC -Linum can be really slow on large files so it does not make sense to -have it on by default. Its probably safe to turn it on when in a -programming mode. +*** nlinum +Linum/NLinum can be really slow on large files so it does not make sense to have +it on by default. Its probably safe to turn it on when in a programming mode. #+BEGIN_SRC emacs-lisp (global-linum-mode -1) -(add-hook 'prog-mode-hook (lambda () (linum-mode t))) +#+END_SRC +#+BEGIN_SRC emacs-lisp +(use-package nlinum + :demand t + :config + (progn + (add-hook 'prog-mode-hook (lambda () (nlinum-mode t))) + (defun imalison-nlinum-mode-hook () + (when nlinum-mode + (setq-local nlinum-format + (concat "%" (number-to-string + ;; Guesstimate number of buffer lines. + (ceiling (log (max 1 (/ (buffer-size) 80)) 10))) + "d")))) + + (add-hook 'nlinum-mode-hook #'imalison-nlinum-mode-hook))) #+END_SRC ** Backups *** Put them all in one directory