用 text-properties-at
读取 face 然后得到正确的 foreground:
$ emacs -Q -f hl-line-mode --eval "
(run-with-idle-timer
0 nil
(lambda ()
(goto-char (point-min))
(let ((face (cadr (memq 'face (text-properties-at (point))))))
(when face
(message (face-foreground (if (consp face) (car face) face) nil t))))))
"
smart-cursor-color
把问题搞复杂了。我用 emacs-29 -Q 试了一下,global-hl-line-mode
的时候,只有上下移动光标的时候背景色是正确的。估计是它里边几个状态 last/default/saved 没管理好。