Highlight the current line while still being able to easily customize/describe underlying faces

| emacs

I use global-hl-line-mode to highlight the current line.

(global-hl-line-mode 1)

However, I don't want hl-line to interfere with the default face suggested by customize-face, which is returned by face-at-point.

(defun my-suggest-other-faces (func &rest args)
  (if global-hl-line-mode
      (progn
        (global-hl-line-mode -1)
        (prog1 (apply func args)
          (global-hl-line-mode 1)))
    (apply func args)))
(advice-add #'face-at-point :around #'my-suggest-other-faces)

Now I can use customize-face and describe-face without hl-line interfering all the time.

This is part of my Emacs configuration.
You can view 1 comment or e-mail me at sacha@sachachua.com.

1 comment

Thanks Sacha! As soon as I saw it I realized this would fix a problem I had been annoyed and baffled by several times without taking the trouble to investigate and solve myself.