4

When I use emacs 24.3.1 and run

/usr/bin/emacs -Q

Then M-< followed by M-xglobal-hl-line-mode and M-xdescribe-face, emacs asks me

Describe face (default `font-lock-comment-delimiter-face'):

But when I use 26.1 and run

/usr/local/bin/emacs -Q

and run exactly the same commands, emacs asks me

Describe face (default ‘hl-line’):

I have to turn hl-line off to get the name of the point's face. What causes this difference and is there a way to get the old behaviour back?

Update:

It seems

(get-char-property (point) 'face)

returns hl-line in 26.1, but returns the actual face in 24.3.1.

1

You are right that describe-face ultimately calls get-char-property (via face-at-point). get-char-property, unlike its cousin get-text-property, doesn't return just text properties, but also overlay properties. And that's how hl-line-mode works: By setting the face property on an overlay.

A cursory glance at Emacs' git repository at savannah.gnu.org, doesn't tell me when and why there was some change. Anyways, you could argue that interactive functions like M-x describe-char should special case hl-line-mode. (Or: That might lead to confusion, so maybe not.) Be that as it may be, a possible temporary fix could be to use advice:

(defun my-face-at-point ()
  (let ((face (get-text-property (point) 'face)))
    (or (and (face-list-p face)
             (car face))
        (and (symbolp face)
             face))))

(defun my-describe-face (&rest ignore)
  (interactive (list (read-face-name "Describe face"
                                     (or (my-face-at-point) 'default)
                                     t)))
  ;; This only needs to change the `interactive` spec, so:
  nil)

(eval-after-load "hl-line"
  '(advice-add 'describe-face :before #'my-describe-face))

You'd have to do that for every interactive function that is affected by this, though, e.g. M-x customize-face, too.

0

At the particular location of interest in the current buffer, type C-u C-x = and that will pull up a *Help* buffer that describes the various faces, text properties, overlays and additional information ... There may be many things happening, and something may be trumping/superseding something else.

As to the default face that is proposed by describe-face if the user were to just press enter without actually inputting any particular face, or as to the difference between various versions of Emacs, I will leave that to another forum participant to create an alternative answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.