From c0bfaec9d45de598d82a5a3d999c59127e02e38f Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 12 Jul 2017 14:53:27 +0200 Subject: [PATCH] Add display-line-numbers support in Emacs 26 #59 --- core/autoload/ui.el | 4 +++- core/core-ui.el | 12 +++++++++++- core/packages.el | 5 +++-- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/core/autoload/ui.el b/core/autoload/ui.el index 357ccea26..ee65ce36b 100644 --- a/core/autoload/ui.el +++ b/core/autoload/ui.el @@ -13,7 +13,9 @@ (defun doom/toggle-line-numbers (&optional arg) "Toggle `linum-mode'." (interactive "P") - (cond ((featurep 'nlinum) + (cond ((boundp 'display-line-numbers) + (setq display-line-numbers (not display-line-numbers))) + ((featurep 'nlinum) (nlinum-mode (or arg (if nlinum-mode -1 +1)))) ((featurep 'linum) (linum-mode (or arg (if linum-mode -1 +1)))) diff --git a/core/core-ui.el b/core/core-ui.el index 3f570a2e9..a43d927a3 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -256,6 +256,13 @@ local value, whether or not it's permanent-local. Therefore, we cycle (add-hook! '(doom-post-init-hook minibuffer-setup-hook) #'doom|no-fringes-in-minibuffer) +;; line numbers in newer version of Emacs +(when (boundp 'display-line-numbers) + (defun doom|init-line-numbers () + (unless (eq major-mode 'org-mode) + (setq display-line-numbers t))) + (add-hook! (prog-mode text-mode) #'doom|init-line-numbers)) + ;; ;; Plugins @@ -318,8 +325,10 @@ local value, whether or not it's permanent-local. Therefore, we cycle (add-hook 'evil-visual-state-exit-hook #'hl-line-mode))) ;; Line number column. A faster (or equivalent, in the worst case) line number -;; plugin than the built-in `linum'. +;; plugin than the built-in `linum'. This will be ignored if you're using Emacs +;; 26.1+, which has native line number support. (def-package! nlinum + :unless (boundp 'display-line-numbers) :commands nlinum-mode :init (defun doom|init-nlinum-mode () @@ -357,6 +366,7 @@ local value, whether or not it's permanent-local. Therefore, we cycle ;; Fixes disappearing line numbers in nlinum and other quirks (def-package! nlinum-hl + :unless (boundp 'display-line-numbers) :after nlinum :config ;; With `markdown-fontify-code-blocks-natively' enabled in `markdown-mode', diff --git a/core/packages.el b/core/packages.el index 349ec0e94..1466d17f9 100644 --- a/core/packages.el +++ b/core/packages.el @@ -17,8 +17,9 @@ (package! fringe-helper) (package! highlight-indentation) (package! highlight-numbers) -(package! nlinum) -(package! nlinum-hl) +(unless (boundp 'display-line-numbers) + (package! nlinum) + (package! nlinum-hl)) (package! rainbow-delimiters) (package! vi-tilde-fringe) (package! visual-fill-column)