Spacemacs での行の強調表示と同じ背景色と区切りスペースに合わせて行番号を正しく配置しようとするのは非常に複雑でした。linum と linum-relative で同時に両方を行うようになった場合に特に重要です。
このコードが正しいかどうかはわかりませんが、これまでのところうまくいきます:
(defun dotspacemacs/user-config ()
"Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration. You are free to put any user code."
(global-linum-mode t)
(unless window-system
(add-hook 'linum-before-numbering-hook
(lambda ()
(setq-local my-linum-format-fmt
(let ((w (length (number-to-string
(count-lines (point-min) (point-max))))))
(concat "%" (number-to-string w) "d"))))
(set-face-attribute 'linum nil
:background (face-background 'hl-line nil t))))
(defface my-linum-hl
`((t :inherit linum :background ,(face-background 'hl-line nil t)))
"Face for the current line number."
:group 'linum)
(defun my-linum-format-func (line)
(concat
(propertize (format my-linum-format-fmt line) 'face 'my-linum-hl)
(propertize " " 'face 'my-linum-hl)))
(unless window-system
(setq linum-format 'my-linum-format-func))
;; linum-relative
(linum-relative-toggle)
(unless window-system
(setq-local my-linum-relative-format-fmt
(let ((w (length (number-to-string
(count-lines (point-min) (point-max))))))
(concat "%" (number-to-string w) "s "))))
(unless window-system
(setq linum-relative-format my-linum-relative-format-fmt))
)
問題: Emacs 内でテーマを変更すると、数字の背景色が正しい色に変わりません。色はそのままです。色のテーマが変更された後、emacs で linum および linum に関連する背景色を更新するにはどうすればよいですか?