unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Cc: Lars Ingebrigtsen <larsi@gnus.org>
Subject: Re: master 79d9f3982f: Add derived-mode test for bug#24176
Date: Mon, 24 Jan 2022 09:53:49 -0500	[thread overview]
Message-ID: <jwvfspd2nml.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <20220124141512.66398C0DA30@vcs2.savannah.gnu.org> (Lars Ingebrigtsen's message of "Mon, 24 Jan 2022 09:15:12 -0500 (EST)")

> +(ert-deftest test-add-font-lock ()
> +  (define-derived-mode mode-a fundamental-mode "mode-a"
> +    (font-lock-add-keywords nil `(("a" 0 'font-lock-keyword-face))))
> +  (define-derived-mode mode-b mode-a "mode-b"
> +    (font-lock-add-keywords nil `(("b" 0 'font-lock-builtin-face))))
> +  (define-derived-mode mode-c mode-b "mode-c"
> +    (font-lock-add-keywords nil `(("c" 0 'font-lock-constant-face))))
> +
> +  (with-temp-buffer
> +    (mode-c)
> +    (should (equal font-lock-keywords
> +                   '(t (("c" 0 'font-lock-constant-face)
> +                        ("b" 0 'font-lock-builtin-face)
> +                        ("a" 0 'font-lock-keyword-face))
> +                       ("c" (0 'font-lock-constant-face))
> +                       ("b" (0 'font-lock-builtin-face))
> +                       ("a" (0 'font-lock-keyword-face)))))))

An interesting other case is:

    (defvar mode-a-flk '(("a" 0 'font-lock-keyword-face)))
    (define-derived-mode mode-a fundamental-mode "mode-a"
      (setq-local font-lock-defaults '(mode-a-flk)))
    (define-derived-mode mode-b mode-a "mode-b"
      (font-lock-add-keywords nil `(("b" 0 'font-lock-builtin-face))))
    (defvar mode-c-flk '(("c" 0 'font-lock-keyword-face)))
    (define-derived-mode mode-c mode-b "mode-c"
      (setq-local font-lock-defaults '(mode-c-flk)))


-- Stefan




       reply	other threads:[~2022-01-24 14:53 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <164303371205.13369.5637099354011397679@vcs2.savannah.gnu.org>
     [not found] ` <20220124141512.66398C0DA30@vcs2.savannah.gnu.org>
2022-01-24 14:53   ` Stefan Monnier [this message]
2022-01-24 17:28     ` master 79d9f3982f: Add derived-mode test for bug#24176 Lars Ingebrigtsen
2022-01-24 22:52       ` Stefan Monnier
2022-01-25 12:16         ` Lars Ingebrigtsen
2022-01-25 13:10           ` Stefan Monnier
2022-01-25 14:39             ` Lars Ingebrigtsen

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=jwvfspd2nml.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.org \
    /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).