* Re: master 79d9f3982f: Add derived-mode test for bug#24176
[not found] ` <20220124141512.66398C0DA30@vcs2.savannah.gnu.org>
@ 2022-01-24 14:53 ` Stefan Monnier
2022-01-24 17:28 ` Lars Ingebrigtsen
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2022-01-24 14:53 UTC (permalink / raw)
To: emacs-devel; +Cc: Lars Ingebrigtsen
> +(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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 79d9f3982f: Add derived-mode test for bug#24176
2022-01-24 14:53 ` master 79d9f3982f: Add derived-mode test for bug#24176 Stefan Monnier
@ 2022-01-24 17:28 ` Lars Ingebrigtsen
2022-01-24 22:52 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-24 17:28 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> 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)))
And font-lock-keywords should then be...
(t (("c" 0 'font-lock-keyword-face)))?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 79d9f3982f: Add derived-mode test for bug#24176
2022-01-24 17:28 ` Lars Ingebrigtsen
@ 2022-01-24 22:52 ` Stefan Monnier
2022-01-25 12:16 ` Lars Ingebrigtsen
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2022-01-24 22:52 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: emacs-devel
Lars Ingebrigtsen [2022-01-24 18:28:34] wrote:
> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>> 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)))
>
> And font-lock-keywords should then be...
> (t (("c" 0 'font-lock-keyword-face)))?
I think so, yes, or maybe b+c, but it definitely should not be a+b.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 79d9f3982f: Add derived-mode test for bug#24176
2022-01-24 22:52 ` Stefan Monnier
@ 2022-01-25 12:16 ` Lars Ingebrigtsen
2022-01-25 13:10 ` Stefan Monnier
0 siblings, 1 reply; 6+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-25 12:16 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
>>> (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)))
>>
>> And font-lock-keywords should then be...
>> (t (("c" 0 'font-lock-keyword-face)))?
>
> I think so, yes, or maybe b+c, but it definitely should not be a+b.
Hm... do you see any obvious way to fix this? We could document that
you have to set font-lock-set-defaults to nil if you're setting
font-lock-defaults in a derived mode, but that's not very
satisfactory... or we could store the value of font-lock-defaults and
check whether it's changed (in font-lock-set-defaults)? Hm...
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 79d9f3982f: Add derived-mode test for bug#24176
2022-01-25 12:16 ` Lars Ingebrigtsen
@ 2022-01-25 13:10 ` Stefan Monnier
2022-01-25 14:39 ` Lars Ingebrigtsen
0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2022-01-25 13:10 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: emacs-devel
>>> And font-lock-keywords should then be...
>>> (t (("c" 0 'font-lock-keyword-face)))?
>> I think so, yes, or maybe b+c, but it definitely should not be a+b.
> Hm... do you see any obvious way to fix this? We could document that
> you have to set font-lock-set-defaults to nil if you're setting
> font-lock-defaults in a derived mode, but that's not very
> satisfactory... or we could store the value of font-lock-defaults and
> check whether it's changed (in font-lock-set-defaults)? Hm...
I'm not completely sure either, no.
I do think we should strive to make `font-lock-add/remove-keywords` work
in a more "declarative" way, such that we can throw away
`font-lock-keywords` and recompute it at any time.
Stefan
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: master 79d9f3982f: Add derived-mode test for bug#24176
2022-01-25 13:10 ` Stefan Monnier
@ 2022-01-25 14:39 ` Lars Ingebrigtsen
0 siblings, 0 replies; 6+ messages in thread
From: Lars Ingebrigtsen @ 2022-01-25 14:39 UTC (permalink / raw)
To: Stefan Monnier; +Cc: emacs-devel
Stefan Monnier <monnier@iro.umontreal.ca> writes:
> I do think we should strive to make `font-lock-add/remove-keywords` work
> in a more "declarative" way, such that we can throw away
> `font-lock-keywords` and recompute it at any time.
Yes, that's a much better idea, I think. So in addition to doing
everything they do now, they'd maintain a list of actions that can be
replayed?
--
(domestic pets only, the antidote for overdose, milk.)
bloggy blog: http://lars.ingebrigtsen.no
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-25 14:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <164303371205.13369.5637099354011397679@vcs2.savannah.gnu.org>
[not found] ` <20220124141512.66398C0DA30@vcs2.savannah.gnu.org>
2022-01-24 14:53 ` master 79d9f3982f: Add derived-mode test for bug#24176 Stefan Monnier
2022-01-24 17:28 ` 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
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.