Fix 'invalid face linum' bug
This commit is contained in:
parent
e7e0f983f1
commit
a51fb5753a
1 changed files with 13 additions and 17 deletions
|
@ -40,17 +40,24 @@
|
||||||
(add-hook! text-mode 'fci-mode))
|
(add-hook! text-mode 'fci-mode))
|
||||||
|
|
||||||
(use-package nlinum ; line numbers
|
(use-package nlinum ; line numbers
|
||||||
:defer t
|
|
||||||
:defines nlinum--width
|
|
||||||
:preface
|
:preface
|
||||||
(defface linum '((t (:inherit default)))
|
|
||||||
"Face for line numbers" :group 'nlinum-mode)
|
|
||||||
(defface linum-highlight-face '((t (:inherit linum)))
|
|
||||||
"Face for line highlights" :group 'nlinum-mode)
|
|
||||||
(defvar narf--hl-nlinum-overlay nil)
|
(defvar narf--hl-nlinum-overlay nil)
|
||||||
(defvar narf--hl-nlinum-line nil)
|
(defvar narf--hl-nlinum-line nil)
|
||||||
(defvar nlinum-format " %3d ")
|
(defvar nlinum-format " %3d ")
|
||||||
:init
|
:init
|
||||||
|
(defface linum-highlight-face '((t (:inherit linum))) "Face for line highlights")
|
||||||
|
(defun narf|nlinum-enable ()
|
||||||
|
(nlinum-mode +1)
|
||||||
|
(add-hook! post-command 'narf|nlinum-hl-line))
|
||||||
|
(defun narf|nlinum-disable ()
|
||||||
|
(nlinum-mode -1)
|
||||||
|
(remove-hook 'post-command-hook 'narf|nlinum-hl-line)
|
||||||
|
(narf|nlinum-unhl-line))
|
||||||
|
|
||||||
|
;; Preset width nlinum
|
||||||
|
(add-hook! (text-mode prog-mode scss-mode web-mode) 'narf|nlinum-enable)
|
||||||
|
(add-hook! org-mode 'narf|nlinum-disable)
|
||||||
|
:config
|
||||||
(defun narf|nlinum-unhl-line ()
|
(defun narf|nlinum-unhl-line ()
|
||||||
"Highlight line number"
|
"Highlight line number"
|
||||||
(when narf--hl-nlinum-overlay
|
(when narf--hl-nlinum-overlay
|
||||||
|
@ -85,17 +92,6 @@
|
||||||
(setq narf--hl-nlinum-overlay ov
|
(setq narf--hl-nlinum-overlay ov
|
||||||
narf--hl-nlinum-line line-no))))))))
|
narf--hl-nlinum-line line-no))))))))
|
||||||
|
|
||||||
(defun narf|nlinum-enable ()
|
|
||||||
(nlinum-mode +1)
|
|
||||||
(add-hook! post-command 'narf|nlinum-hl-line))
|
|
||||||
(defun narf|nlinum-disable ()
|
|
||||||
(nlinum-mode -1)
|
|
||||||
(remove-hook 'post-command-hook 'narf|nlinum-hl-line)
|
|
||||||
(narf|nlinum-unhl-line))
|
|
||||||
|
|
||||||
;; Preset width nlinum
|
|
||||||
(add-hook! (text-mode prog-mode scss-mode web-mode) 'narf|nlinum-enable)
|
|
||||||
(add-hook! org-mode 'narf|nlinum-disable)
|
|
||||||
(add-hook! nlinum-mode
|
(add-hook! nlinum-mode
|
||||||
(setq nlinum--width (length (number-to-string (count-lines (point-min) (point-max)))))))
|
(setq nlinum--width (length (number-to-string (count-lines (point-min) (point-max)))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue