bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71469: font-lock does not apply standard faces and their descendants


From: Eli Zaretskii
Subject: bug#71469: font-lock does not apply standard faces and their descendants
Date: Mon, 10 Jun 2024 15:55:57 +0300

tags 71469 notabug
thanks

> From: Konstantin Kharlamov <Hi-Angel@yandex.ru>
> Date: Mon, 10 Jun 2024 14:59:37 +0300
> 
>      (defface test-face
>        '((t (:inherit bold)))
>        "Test face.")
> 
>      (define-derived-mode my-mode fundamental-mode "My Mode"
>        "A minimal mode that highlights 'hello world' text."
>        (font-lock-add-keywords nil '(("hello world" 0 test-face)))

>From the ELisp manual:

   Each element of ‘font-lock-keywords’ should have one of these forms:
   [...]
  ‘(MATCHER . FACESPEC)’
       In this kind of element, FACESPEC is an expression whose value
       specifies the face to use for highlighting.  In the simplest case,
       FACESPEC is a Lisp variable (a symbol) whose value is a face name.
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

IOW, there's a difference between a symbol of a variable whose value
is a face name, and that face name itself.

This works for me:

  (defface test-face
    '((t (:inherit bold)))
    "Test face.")
  (defvar test-face 'test-face
    "Face name to use for My Mode.")

  (define-derived-mode my-mode fundamental-mode "My Mode"
    "A minimal mode that highlights 'hello world' text."
    (font-lock-add-keywords nil '(("hello world" 0 test-face)))
    (font-lock-flush))
  (add-to-list 'auto-mode-alist (cons "test.txt" 'my-mode))
  (provide 'my-mode)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]