From 6dff6e124b10cd31adc12cd5149635ce844f6b7a Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 14 Jun 2017 02:51:24 +0200 Subject: [PATCH] Bring back nlinum-hl I moved the nlinum--region fix to the nlinum-hl package; which also contains fixes for other problematic major-modes. --- core/core-ui.el | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-) diff --git a/core/core-ui.el b/core/core-ui.el index d73a21b21..3265775b9 100644 --- a/core/core-ui.el +++ b/core/core-ui.el @@ -282,34 +282,6 @@ file." :config (setq nlinum-highlight-current-line t) - ;; fix for disappearing line numbers in nlinum - ;; - (defun doom*nlinum-region (start limit) - (save-excursion - (let ((inhibit-point-motion-hooks t)) - (goto-char start) - (unless (bolp) (forward-line 1)) - (remove-overlays (point) limit 'nlinum t) - (let ((line (nlinum--line-number-at-pos))) - (while - (and (not (eobp)) (<= (point) limit) - (let* ((ol (make-overlay (point) (1+ (point)))) - (str (funcall nlinum-format-function - line nlinum--width)) - (width (string-width str))) - (when (< nlinum--width width) - (setq nlinum--width width) - (nlinum--flush)) - (overlay-put ol 'nlinum t) - (overlay-put ol 'evaporate t) - (overlay-put ol 'before-string - (propertize " " 'display - `((margin left-margin) ,str))) - (setq line (1+ line)) - (zerop (forward-line 1)))))))) - nil) - (advice-add #'nlinum--region :override #'doom*nlinum-region) - ;; Optimization: calculate line number column width beforehand (defun doom|init-nlinum-width () (setq nlinum--width @@ -317,6 +289,24 @@ file." (format-mode-line "%l"))))) (add-hook 'nlinum-mode-hook #'doom|init-nlinum-width)) +;; Fixes disappearing line numbers in nlinum and other quirks +(def-package! nlinum-hl + :load-path "~/work/plugins/emacs-nlinum-hl/" + :after nlinum + :config + ;; With `markdown-fontify-code-blocks-natively' enabled in `markdown-mode', + ;; line numbers tend to vanish next to code blocks. + (advice-add #'markdown-fontify-code-block-natively + :after #'nlinum-hl-do-markdown-fontify-region) + + ;; When using `web-mode's code-folding an entire range of line numbers will + ;; vanish in the affected area. + (advice-add #'web-mode-fold-or-unfold :after #'nlinum-hl-do-generic-flush) + + ;; Changing fonts can leave nlinum line numbers in their original size; this + ;; forces them to resize. + (advice-add #'set-frame-font :after #'nlinum-hl-flush-all-windows)) + ;; Helps us distinguish stacked delimiter pairs. Especially in parentheses-drunk ;; languages like Lisp. (def-package! rainbow-delimiters