From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#69431: 30.0.50; Strange fontificaion behavior Date: Sun, 07 Apr 2024 11:29:25 -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> <87cyr2pc9t.fsf@localhost> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="31167"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: =?UTF-8?Q?Bj=C3=B6rn?= Bidar , Ihor Radchenko , Eli Zaretskii , 69431@debbugs.gnu.org, hirofumi@mail.parknet.co.jp To: Andrea Corallo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Apr 07 17:30:11 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 1rtUTB-0007pS-Oj for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 07 Apr 2024 17:30:10 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rtUSz-0000BN-DW; Sun, 07 Apr 2024 11:29:57 -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 1rtUSx-0000Az-EC for bug-gnu-emacs@gnu.org; Sun, 07 Apr 2024 11:29:55 -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 1rtUSx-0003FB-5N for bug-gnu-emacs@gnu.org; Sun, 07 Apr 2024 11:29:55 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rtUT3-0004f1-W7 for bug-gnu-emacs@gnu.org; Sun, 07 Apr 2024 11:30:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 07 Apr 2024 15:30:01 +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.171250378717823 (code B ref 69431); Sun, 07 Apr 2024 15:30:01 +0000 Original-Received: (at 69431) by debbugs.gnu.org; 7 Apr 2024 15:29:47 +0000 Original-Received: from localhost ([127.0.0.1]:44339 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtUSp-0004dP-2i for submit@debbugs.gnu.org; Sun, 07 Apr 2024 11:29:47 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:63603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rtUSn-0004cb-Tv for 69431@debbugs.gnu.org; Sun, 07 Apr 2024 11:29:46 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 050481000FC; Sun, 7 Apr 2024 11:29:33 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1712503767; bh=Js464nZEJrQ9O64tqcKvkSm6rDNxDkEkb/7HacY5r7c=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Rh6pCww49gV5q5YjT4SycMA33vnsBSbmJr5qTie6Ykr/emmqiMvRg9UHzMbmnBsbG 6PS/MuMYeToadiTFSF7aZQUC9NReOo9splMnlFADZO+E/fBu/jwHndkX8i4ukaNyAL Lt5w9FnArOK2EwIq3QbpR1RTvVH/romflq6k4Cvp+UbOA+jhuN8/d1N3TZ0gqeIS5E X+2KUqm9rJ0gAJ8J5JsqNenDlqgY0XgPhtfsVt8qjg/PXpSf7hDryawYYn74SAD8T5 VLumscaPIqPTkH7shVFrP/vZbtxQmei84gyuf2yps93g+CKTV5fTtgcI3oq9o2O9ss GzIhnowRUr8rA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 5156B10004A; Sun, 7 Apr 2024 11:29:27 -0400 (EDT) Original-Received: from alfajor (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 0F95C12033B; Sun, 7 Apr 2024 11:29:27 -0400 (EDT) In-Reply-To: (Andrea Corallo's message of "Sun, 07 Apr 2024 03:47:46 -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:282876 Archived-At: --=-=-= Content-Type: text/plain > 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=globalized-modes.patch 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 () --=-=-=--