unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Konstantin Kharlamov <Hi-Angel@yandex.ru>
Cc: 71469@debbugs.gnu.org
Subject: bug#71469: font-lock does not apply standard faces and their descendants
Date: Mon, 10 Jun 2024 15:55:57 +0300	[thread overview]
Message-ID: <86tti17y8y.fsf@gnu.org> (raw)
In-Reply-To: <abcb0453868da407f23e412ad31f39b927186ae7.camel@yandex.ru> (message from Konstantin Kharlamov on Mon, 10 Jun 2024 14:59:37 +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	other threads:[~2024-06-10 12:55 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-10 11:59 bug#71469: font-lock does not apply standard faces and their descendants Konstantin Kharlamov
2024-06-10 12:55 ` Eli Zaretskii [this message]
2024-06-10 13:41   ` bug#71469: [PATCH] " Konstantin Kharlamov
2024-06-10 15:17     ` Eli Zaretskii
2024-06-10 17:26       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=86tti17y8y.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=71469@debbugs.gnu.org \
    --cc=Hi-Angel@yandex.ru \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).