all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Andrea Corallo <acorallo@gnu.org>
Cc: "Björn Bidar" <bjorn.bidar@thaodan.de>,
	"Ihor Radchenko" <yantar92@posteo.net>,
	"Eli Zaretskii" <eliz@gnu.org>,
	69431@debbugs.gnu.org, hirofumi@mail.parknet.co.jp
Subject: bug#69431: 30.0.50; Strange fontificaion behavior
Date: Sun, 07 Apr 2024 11:29:25 -0400	[thread overview]
Message-ID: <jwv4jcdyz42.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <yp1edbhlil9.fsf@fencepost.gnu.org> (Andrea Corallo's message of "Sun, 07 Apr 2024 03:47:46 -0400")

[-- Attachment #1: Type: text/plain, Size: 521 bytes --]

> I'd like to have Stefan opinion if this is okay

It's an ugly workaround, so it would need some comment.

> or we have a better way to fix this.

Yes, it's a problem in `easy-mmode.el`.  I think the patch below should
fix it (it'll need recompiling those files which define globalized
minor modes before it gets effective).

Actually, nowadays modes that don't use `run-mode-hooks` should be
vanishingly rare and I think we could "drop support" for them, which
would significantly simplify that macro.


        Stefan

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: globalized-modes.patch --]
[-- Type: text/x-diff, Size: 2883 bytes --]

diff --git a/lisp/emacs-lisp/easy-mmode.el b/lisp/emacs-lisp/easy-mmode.el
index 4fa05008dd8..55cda4c5aea 100644
--- a/lisp/emacs-lisp/easy-mmode.el
+++ b/lisp/emacs-lisp/easy-mmode.el
@@ -493,6 +493,8 @@ define-globalized-minor-mode
 	 (extra-keywords nil)
          (MODE-variable mode)
 	 (MODE-buffers (intern (concat global-mode-name "-buffers")))
+	 (MODE-enable-in-buffer
+	  (intern (concat global-mode-name "-enable-in-buffer")))
 	 (MODE-enable-in-buffers
 	  (intern (concat global-mode-name "-enable-in-buffers")))
 	 (MODE-check-buffers
@@ -559,10 +561,10 @@ define-globalized-minor-mode
 	 (if ,global-mode
 	     (progn
 	       (add-hook 'after-change-major-mode-hook
-			 #',MODE-enable-in-buffers)
+			 #',MODE-enable-in-buffer)
 	       (add-hook 'find-file-hook #',MODE-check-buffers)
 	       (add-hook 'change-major-mode-hook #',MODE-cmhh))
-	   (remove-hook 'after-change-major-mode-hook #',MODE-enable-in-buffers)
+	   (remove-hook 'after-change-major-mode-hook #',MODE-enable-in-buffer)
 	   (remove-hook 'find-file-hook #',MODE-check-buffers)
 	   (remove-hook 'change-major-mode-hook #',MODE-cmhh))
 
@@ -609,6 +611,22 @@ define-globalized-minor-mode
        ;; List of buffers left to process.
        (defvar ,MODE-buffers nil)
 
+       ;; The function that calls TURN-ON in the current buffer.
+       (defun ,MODE-enable-in-buffer ()
+         (setq ,MODE-buffers (delq (current-buffer) ,MODE-buffers))
+         (unless ,MODE-set-explicitly
+           (unless (eq ,MODE-major-mode major-mode)
+             (if ,MODE-variable
+                 (progn
+                   (,mode -1)
+                   (funcall ,turn-on-function))
+               (funcall ,turn-on-function))))
+         (setq ,MODE-major-mode major-mode))
+       (put ',MODE-enable-in-buffer 'definition-name ',global-mode)
+
+       ;; All the functions below are trying to handle those
+       ;;  major modes which don't use `run-mode-hooks'.
+
        ;; The function that calls TURN-ON in each buffer.
        (defun ,MODE-enable-in-buffers ()
          (let ((buffers ,MODE-buffers))
@@ -618,15 +636,8 @@ define-globalized-minor-mode
            (setq ,MODE-buffers nil)
            (dolist (buf buffers)
              (when (buffer-live-p buf)
-               (with-current-buffer buf
-                 (unless ,MODE-set-explicitly
-                   (unless (eq ,MODE-major-mode major-mode)
-                     (if ,MODE-variable
-                         (progn
-                           (,mode -1)
-                           (funcall ,turn-on-function))
-                       (funcall ,turn-on-function))))
-                 (setq ,MODE-major-mode major-mode))))))
+              (with-current-buffer buf
+                (,MODE-enable-in-buffer))))))
        (put ',MODE-enable-in-buffers 'definition-name ',global-mode)
 
        (defun ,MODE-check-buffers ()

  parent reply	other threads:[~2024-04-07 15:29 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-27 16:58 bug#69431: 30.0.50; Strange fontificaion behavior OGAWA Hirofumi
2024-02-27 17:29 ` Eli Zaretskii
2024-02-27 17:58   ` Ihor Radchenko
2024-02-27 18:49     ` Eli Zaretskii
2024-02-27 19:20       ` OGAWA Hirofumi
2024-02-27 19:26       ` Ihor Radchenko
2024-02-27 19:33         ` Eli Zaretskii
2024-02-27 20:11           ` Andrea Corallo
2024-02-27 20:23             ` OGAWA Hirofumi
2024-02-27 20:24             ` Ihor Radchenko
2024-02-27 20:27             ` Ihor Radchenko
2024-02-27 21:48               ` Andrea Corallo
2024-02-28 12:00                 ` Ihor Radchenko
     [not found]           ` <87v869h86b.fsf@>
2024-02-28 13:53             ` Andrea Corallo
2024-02-28 16:57               ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]               ` <87zfvkfrw0.fsf@>
2024-02-28 18:44                 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-28 19:34                 ` Andrea Corallo
2024-02-28 21:41                   ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]                   ` <87jzmofes3.fsf@>
2024-02-29 22:16                     ` Andrea Corallo
2024-03-01  1:13                       ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-01  1:18                       ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-03 16:20               ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]               ` <87bk7vgucb.fsf@>
2024-03-03 17:01                 ` Andrea Corallo
2024-03-06 16:38         ` Andrea Corallo
2024-03-07 11:59           ` OGAWA Hirofumi
2024-03-07 14:49             ` Andrea Corallo
2024-03-07 22:33               ` Andrea Corallo
2024-03-21  8:32                 ` Eli Zaretskii
2024-03-23 19:29                   ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]                   ` <87frwgeohj.fsf@>
2024-03-23 20:34                     ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-23 20:34                     ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-24  9:12                   ` Andrea Corallo
2024-03-24  9:28                     ` Eli Zaretskii
2024-03-26 21:37                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-27  8:31                       ` Andrea Corallo
2024-03-27 14:27                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-31 19:49                           ` Andrea Corallo
2024-03-31 20:40                             ` Andrea Corallo
2024-04-01 10:59                               ` Ihor Radchenko
2024-04-01 12:33                               ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-06 17:01                               ` Andrea Corallo
2024-04-06 18:38                                 ` Ihor Radchenko
2024-04-07  7:47                                   ` Andrea Corallo
     [not found]                                     ` <87plv1v3za.fsf@>
2024-04-07 11:46                                       ` Eli Zaretskii
2024-04-07 12:01                                         ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]                                         ` <875xwtidpn.fsf@>
2024-04-07 12:48                                           ` Eli Zaretskii
     [not found]                                             ` <871q7hi5f9.fsf@>
2024-04-07 15:50                                               ` Eli Zaretskii
2024-04-07 18:02                                                 ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]                                                 ` <87v84tgifz.fsf@>
2024-04-07 18:35                                                   ` Eli Zaretskii
2024-04-07 19:09                                                     ` Björn Bidar via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-04-08  7:15                                                   ` Andrea Corallo
2024-04-08 11:40                                                     ` Eli Zaretskii
2024-04-07 12:29                                       ` Andrea Corallo
2024-04-07 15:29                                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2024-04-08  7:00                                       ` Andrea Corallo
2024-04-08 12:49                                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-03-07 14:31           ` Ihor Radchenko

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

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

  git send-email \
    --in-reply-to=jwv4jcdyz42.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=69431@debbugs.gnu.org \
    --cc=acorallo@gnu.org \
    --cc=bjorn.bidar@thaodan.de \
    --cc=eliz@gnu.org \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=monnier@iro.umontreal.ca \
    --cc=yantar92@posteo.net \
    /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 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.