From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Andrea Corallo Newsgroups: gmane.emacs.bugs Subject: bug#69431: 30.0.50; Strange fontificaion behavior Date: Sun, 31 Mar 2024 16:40:34 -0400 Message-ID: References: <871q8x6e06.fsf@mail.parknet.co.jp> <86msrlu87i.fsf@gnu.org> <87v869oklj.fsf@localhost> <86il29u4hy.fsf@gnu.org> <87sf1dogi8.fsf@localhost> <87h6hi8d87.fsf@mail.parknet.co.jp> <86il1g2dfd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35407"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 69431@debbugs.gnu.org, =?UTF-8?Q?Bj=C3=B6rn?= Bidar , Eli Zaretskii , yantar92@posteo.net, hirofumi@mail.parknet.co.jp To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Mar 31 22:42:09 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rr20H-00091T-Iz for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 31 Mar 2024 22:42:09 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rr209-0000YQ-Vl; Sun, 31 Mar 2024 16:42:02 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rr207-0000Xs-VF for bug-gnu-emacs@gnu.org; Sun, 31 Mar 2024 16:41:59 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rr207-0003ZG-MN for bug-gnu-emacs@gnu.org; Sun, 31 Mar 2024 16:41:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rr20A-0000J7-Bv for bug-gnu-emacs@gnu.org; Sun, 31 Mar 2024 16:42:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Andrea Corallo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 31 Mar 2024 20:42:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69431 X-GNU-PR-Package: emacs Original-Received: via spool by 69431-submit@debbugs.gnu.org id=B69431.1711917665937 (code B ref 69431); Sun, 31 Mar 2024 20:42:02 +0000 Original-Received: (at 69431) by debbugs.gnu.org; 31 Mar 2024 20:41:05 +0000 Original-Received: from localhost ([127.0.0.1]:48569 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rr1zE-0000F0-6q for submit@debbugs.gnu.org; Sun, 31 Mar 2024 16:41:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47198) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rr1zC-0000EB-1j for 69431@debbugs.gnu.org; Sun, 31 Mar 2024 16:41:03 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rr1z0-0002o5-7a; Sun, 31 Mar 2024 16:40:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:References:In-Reply-To:Subject:To: From; bh=QF9Qz+Bk3deKHOeon9MbGnfefgVqnhQd8iJOn7mGd5s=; b=HD6y/1JR5T/hqG1eUjGj V40Vv9Xdnof8Xlhr7b9iOz7aLrQ/RnEDO2W/TfcJyMS5gDUuLgtjRgAkPjFO09S3zNRJJ9kWfVLZt 13xjkNQWsbiteC3scjOn5FfduSf7szLz0W3Cqbb0N9J1hTq6tLOLd5bjPVzMY70w47sBOP3o3NkoT YLh0w7jwuob7E927EXhIJgfJxEhLRCE3gQg3VhtalS0MNFAP6J5N3Zw9fa0RzTlmNSi5cdDQnHUo4 CcB2vcQhR6l7Yfo0HqJddc1y5G3ghMxm1kDFzJxPKGj6JQiNG7HhfE9LLkCcDLLonY21IhWAiMPaF QYB9actg5WK+mg==; Original-Received: from acorallo by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1rr1yk-0004GE-CE; Sun, 31 Mar 2024 16:40:39 -0400 In-Reply-To: (Andrea Corallo's message of "Sun, 31 Mar 2024 15:49:08 -0400") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:282448 Archived-At: Andrea Corallo writes: > Stefan Monnier writes: > >>>>> I'm trying to progress on this but I've difficult time at getting a grip >>>>> on this bug. One of the reason why is that on my reproducer Emacs >>>>> doesn't crash nor complain, the other reason is that I'm not really into >>>>> our fontification. I'll keep on looking into it but I'd appretiate any >>>>> hint like: what should be happening to fontify the buffer that is not >>>>> actually happening here? With such info I could try investingating the >>>>> issue from there comparing with the working case. >>>> >>>> Hmm... here, after >>>> >>>> rm -rf ~/.emacs.d/eln-cache >>>> src/emacs -Q --eval '(setq debug-on-error t)' a.org >>>> >>>> I get a buffer with no fontification, that claims to be in Org mode but >>>> whose `font-lock-keywords` is just (t nil), which explains the lack >>>> of fontification. >>> >>> Where `font-lock-keywords` are supposed to be set? >> >> `font-lock-keywords` is normally set from `font-lock-defaults` (which is >> set by the major-mode) by `font-lock-set-defaults` when `font-lock-mode` >> is enabled (which usually happens soon after enabling the major mode, >> via `after-change-major-mode-hook`). > > Sorry didn't had much time to progress on this. > > I see `font-lock-mode` and `font-lock-set-defaults` are called when > opening an org file here on my reproducer. > > Also I see `font-lock-set-defaults` is actually set! So I'm wondering > why afterwards the value changes for my test.org. > > Will look into it more hopefully tomorrow. Driven by curiosity I went a little further today... I've applied the following: ================ 1 file changed, 6 insertions(+) lisp/font-lock.el | 6 ++++++ modified lisp/font-lock.el @@ -1874,6 +1874,10 @@ font-lock-refresh-defaults (defvar-local font-lock-major-mode nil "Major mode for which the font-lock settings have been setup.") +(defun k-variable-watcher (_symbol newval op _buffer) + (message "XXX %s" op) + (backtrace)) + (defun font-lock-set-defaults () "Set fontification defaults appropriately for this mode. Sets various variables using `font-lock-defaults' and @@ -1934,6 +1938,8 @@ font-lock-set-defaults (unless (eq (car font-lock-keywords) t) (setq font-lock-keywords (font-lock-compile-keywords font-lock-keywords)))) + (when (string= (buffer-name) "test.org") + (add-variable-watcher 'font-lock-keywords #'k-variable-watcher)) (font-lock-flush))) ^L ;;; Color etc. support. ================ And this is what it logs on *Messages* depending on the fact that the eln-cache is wiped or not: Warm eln-cache (working fontification) ================ For information about GNU Emacs and the GNU system, type C-h C-a. XXX set backtrace() k-variable-watcher(font-lock-keywords ((org-font-lock-hook) ("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1)) (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) ("^[ \11]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" (1 'org-table t)) ("^[ \11]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t)) ("^[ \11]*| *\\([#*]\\) *|" (1 'org-formula t)) ("^[ \11]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t)) ("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t)) ("^\\(?4:[ \11]*\\)\\(?1::\\(?2:\\S-+\\):\\)\\(?:\\(?3:$\\)\\|[ \11]+\\(?3:.*?\\)\\)\\(?5:[ \11]*\\)$" (1 'org-special-keyword t) (3 'org-property-value t)) (org-fontify-drawers) (org-activate-links) (org-activate-tags (1 'org-tag prepend)) (org-activate-target-links (1 'org-link t)) (org-activate-dates (0 'org-date t)) (org-activate-footnote -links)\ ("<<<\\([^<>\n\15 \11]\\|[^<>\n\15 \11][^<>\n\15]*[^<>\n\15 \11]\\)>>>" (0 'org-target t)) ("<<\\([^<>\n\15 \11]\\|[^<>\n\15 \11][^<>\n\15]*[^<>\n\15 \11]\\)>>" (0 'org-target t)) ("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) (org-fontify-macros) ("^\\(\\*+\\)\\(?: +\\(DONE\\|TODO\\)\\)\\(?: +\\(.*?\\)\\)?[ \11]*$" (2 (org-get-todo-face 2) prepend)) ("^\\(\\*+\\)\\(?: +\\(?:DONE\\)\\)\\(?: +\\(.*?\\)\\)?[ \11]*$" (2 'org-headline-done prepend)) (org-font-lock-add-priority-faces) (org-font-lock-add-tag-faces) ("\\) normal-mode(t) after-find-file(nil t) find-file-noselect-1(# "~/test.org" nil nil "~/test.org" (14180533 64513)) find-file-noselect("/home/andcor03/test.org") command-line-1(("-eval" "(setq native-comp-jit-compilation t)" "/home/andcor03/test.org")) command-line() normal-top-level() XXX set backtrace() k-variable-watcher(font-lock-keywords (t ((org-font-lock-hook) ("^\\(\\**\\)\\(\\* \\)\\(.*\\)" (1 (org-get-level-face 1)) (2 (org-get-level-face 2)) (3 (org-get-level-face 3))) ("^[ \11]*\\(\\(|\\|\\+-[-+]\\).*\\S-\\)" (1 'org-table t)) ("^[ \11]*|\\(?:.*?|\\)? *\\(:?=[^|\n]*\\)" (1 'org-formula t)) ("^[ \11]*| *\\([#*]\\) *|" (1 'org-formula t)) ("^[ \11]*|\\( *\\([$!_^/]\\) *|.*\\)|" (1 'org-formula t)) ("| *\\(<[lrc]?[0-9]*>\\)" (1 'org-formula t)) ("^\\(?4:[ \11]*\\)\\(?1::\\(?2:\\S-+\\):\\)\\(?:\\(?3:$\\)\\|[ \11]+\\(?3:.*?\\)\\)\\(?5:[ \11]*\\)$" (1 'org-special-keyword t) (3 'org-property-value t)) (org-fontify-drawers) (org-activate-links) (org-activate-tags (1 'org-tag prepend)) (org-activate-target-links (1 'org-link t)) (org-activate-dates (0 'org-date t)) (org-activate-footn ote-lin\ ks) ("<<<\\([^<>\n\15 \11]\\|[^<>\n\15 \11][^<>\n\15]*[^<>\n\15 \11]\\)>>>" (0 'org-target t)) ("<<\\([^<>\n\15 \11]\\|[^<>\n\15 \11][^<>\n\15]*[^<>\n\15 \11]\\)>>" (0 'org-target t)) ("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) (org-fontify-macros) ("^\\(\\*+\\)\\(?: +\\(DONE\\|TODO\\)\\)\\(?: +\\(.*?\\)\\)?[ \11]*$" (2 (org-get-todo-face 2) prepend)) ("^\\(\\*+\\)\\(?: +\\(?:DONE\\)\\)\\(?: +\\(.*?\\)\\)?[ \11]*$" (2 'org-headline-done prepend)) (org-font-lock-add-priority-faces) (org-font-lock-add-tag-faces) ("\\\\)" (1 'org-formula t)) ("^\\(?4:[ \11]*\\)\\(?1::\\(?2:\\S-+\\):\\)\\(?:\\(?3:$\\)\\|[ \11]+\\(?3:.*?\\)\\)\\(?5:[ \11]*\\)$" (1 'org-special-keyword t) (3 'org-property-value t)) (org-fontify-drawers (0 nil)) (org-activate-links (0 nil)) (org-activate-tags (1 'org-tag prepend)) (org-activate-target-links (1 'org-link t)) (org-activate-dates (0 'org-date t)) (org-activate-footnote-links (0 nil)) ("<<<\\([^<>\n\15 \11]\\|[^<>\n\15 \11][^<>\n\15]*[^<>\n\15 \11]\\)>>>" (0 'or\ g-target t)) ("<<\\([^<>\n\15 \11]\\|[^<>\n\15 \11][^<>\n\15]*[^<>\n\15 \11]\\)>>" (0 'org-target t)) ("^&?%%(.*\\|<%%([^>\n]*?>" (0 'org-sexp-date t)) (org-fontify-macros (0 nil)) ("^\\(\\*+\\)\\(?: +\\(DONE\\|TODO\\)\\)\\(?: +\\(.*?\\)\\)?[ \11]*$" (2 (org-get-todo-face 2) prepend)) ("^\\(\\*+\\)\\(?: +\\(?:DONE\\)\\)\\(?: +\\(.*?\\)\\)?[ \11]*$" (2 'org-headline-done prepend)) (org-font-lock-add-priority-faces (0 nil)) (org-font-lock-add-tag-faces (0 nil)) ("\\) font-lock-fontify-keywords-region(1 7 nil) font-lock-default-fontify-region(1 7 nil) font-lock-fontify-region(1 7) #f(compiled-function (fun) #)(font-lock-fontify-region) jit-lock--run-functions(1 7) jit-lock-fontify-now(1 7) jit-lock-function(1) redisplay_internal\ \(C\ function\)() ================ Empty eln-cache (fontification broken): ================ For information about GNU Emacs and the GNU system, type C-h C-a. XXX makunbound backtrace() k-variable-watcher(font-lock-keywords nil makunbound #) kill-local-variable(font-lock-keywords) org-set-font-lock-defaults() org-mode() set-auto-mode-0(org-mode nil) set-auto-mode--apply-alist((("\\.gpg\\(~\\|\\.~[0-9]+~\\)?\\'" nil epa-file) ("\\.elc\\'" . elisp-byte-code-mode) ("\\.zst\\'" nil jka-compr) ("\\.dz\\'" nil jka-compr) ("\\.xz\\'" nil jka-compr) ("\\.lzma\\'" nil jka-compr) ("\\.lz\\'" nil jka-compr) ("\\.g?z\\'" nil jka-compr) ("\\.bz2\\'" nil jka-compr) ("\\.Z\\'" nil jka-compr) ("\\.vr[hi]?\\'" . vera-mode) ("\\(?:\\.\\(?:rbw?\\|ru\\|rake\\|thor\\|axlsx\\|jbuilder\\|rabl\\|gemspec\\|podspec\\)\\|/\\(?:Gem\\|Rake\\|Cap\\|Thor\\|Puppet\\|Berks\\|Brew\\|Fast\\|Vagrant\\|Guard\\|Pod\\)file\\)\\'" . ruby-mode) ("\\.re?st\\'" . rst-mode) ("/\\(?:Pipfile\\|\\.?flake8\\)\\'" . conf-mode) ("\\.py[iw]?\\'" . python-mode) ("\\.m\\'" . octave-maybe-mode) ("\\.less\\'" . less-css-mode) ("\\.scss\\'" . scss-mode) ("\\.cs\\'" . csharp-mode) ("\\.aw k\\'" .\ awk-mode) ("\\.\\(u?lpc\\|pike\\|pmod\\(\\.in\\)?\\)\\'" . pike-mode) ("\\.idl\\'" . idl-mode) ("\\.java\\'" . java-mode) ("\\.m\\'" . objc-mode) ("\\.ii\\'" . c++-mode) ("\\.i\\'" . c-mode) ("\\.lex\\'" . c-mode) ("\\.y\\(acc\\)?\\'" . c-mode) ("\\.h\\'" . c-or-c++-mode) ("\\.c\\'" . c-mode) ("\\.\\(CC?\\|HH?\\)\\'" . c++-mode) ("\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\'" . c++-mode) ("\\.\\(cc\\|hh\\)\\'" . c++-mode) ("\\.\\(bat\\|cmd\\)\\'" . bat-mode) ("\\.[sx]?html?\\(\\.[a-zA-Z_]+\\)?\\'" . mhtml-mode) ("\\.svgz?\\'" . image-mode) ("\\.svgz?\\'" . xml-mode) ("\\.x[bp]m\\'" . image-mode) ("\\.x[bp]m\\'" . c-mode) ("\\.p[bpgn]m\\'" . image-mode) ("\\.tiff?\\'" . image-mode) ("\\.gif\\'" . image-mode) ("\\.png\\'" . image-mode) ("\\.jpe?g\\'" . image-mode) ("\\.webp\\'" . image-mode) ("\\.te?xt \\'" . \ text-mode) ("\\.[tT]e[xX]\\'" . tex-mode) ("\\.ins\\'" . tex-mode) ("\\.ltx\\'" . latex-mode) ("\\.dtx\\'" . doctex-mode) ...) nil nil) set-auto-mode() normal-mode(t) after-find-file(nil t) find-file-noselect-1(# "~/test.org" nil nil "~/test.org" (14180533 64513)) find-file-noselect("/home/andcor03/test.org") command-line-1(("-eval" "(setq native-comp-jit-compilation t)" "/home/andcor03/test.org")) command-line() normal-top-level() XXX set backtrace() k-variable-watcher(font-lock-keywords (t nil) set nil) font-lock-fontify-keywords-region(1 7 nil) font-lock-default-fontify-region(1 7 nil) font-lock-fontify-region(1 7) #f(compiled-function (fun) #)(font-lock-fontify-region) jit-lock--run-functions(1 7) jit-lock-fontify-now(1 7) jit-lock-function(1) redisplay_internal\ \(C\ function\)() ================ So from what I see in the non working example 'font-lock-keywords' is cleared at the end of 'org-set-font-lock-defaults' which does '(kill-local-variable 'font-lock-keywords)'. Now why this is not happening in the working example I'm not sure ATM, ('org-set-font-lock-defaults' is not even called there AFAICS). Maybe org maintainers can comment if this is expected or not, or explain meanwhile the mechanism so debug will be easier. Thanks! Andrea