After some answers I got it.
The answers in other threads didn't work right away in Spacemacs (I'm really new to Emacs world so I don't know why), but mixing parts of them I managed to do it.
It's still not perfect. I would prefer to get the color from Emacs theme instead of using the color that hl-line figures out it should use, but I don't understand how to do it.
Thank you all for your help!
(defun dotspacemacs/user-config ()
(global-linum-mode t)
(unless window-system
(add-hook 'linum-before-numbering-hook
(lambda ()
(setq-local linum-format-fmt
(let ((w (length (number-to-string
(count-lines (point-min) (point-max))))))
(concat "%" (number-to-string w) "d"))))))
(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 linum-format-fmt line) 'face 'linum)
(propertize (format linum-format-fmt line) 'face 'my-linum-hl)
(propertize " " 'face 'mode-line)))
(unless window-system
(setq linum-format 'my-linum-format-func)))
hl-line-mode
andlinum-mode
, and asking whether the current line can match the background color used byhl-line-mode
? And are you also asking that this be programmatically so smart that it automatically adjusts as you switch between the various themes that may also set faces that are different for both of the above-mentioned minor-modes?phils
wrote up a solution a few years ago that highlights the current line inlinum-mode
: stackoverflow.com/a/10593165/2112489 In terms of the second question, it doesn't sound like that is easily accomplished.M-x find-library RET hl-line RET
-- it is only 270 lines and the facehl-line-face
is the sixth definition down from the top. See alsohl-line
face (fifth from the top). The default is thehighlight
face.