Subject: bug#70671: 30.0.50; mhtml-mode ignores delay-mode-hooks

From: Ihor Radchenko <[email-masked]>
Date: Fri, 03 May 2024 07:48:29 +0000

Stefan Monnier <[email-masked]> writes:

>>> May mhtml-mode be changed to use (run-mode-hooks 'prog-mode-hook)
>>> instead, so that `delay-mode-hooks' is honoured?
>> ...
>> Stefan, WDYT?
>
> It should use `run-mode-hooks`, indeed, thanks,

See the attached patch.

>From a73131234019d51b93cf6422fc86218d962167d4 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Ihor Radchenko <[email-masked]>
Date: Fri, 3 May 2024 10:46:22 +0300
Subject: [PATCH] mhtml-mode: Use `run-mode-hook' to run `prog-mode-hook'
 (bug#70671)

* lisp/textmodes/mhtml-mode.el (mhtml-mode): When running hooks
simulating inheritance from `prog-mode', use `run-mode-hooks' that
honors `delay-mode-hooks' macro.  Note that `delay-mode-hooks' is bound
to non-nil when major mode body is evaluated, so there is no chance that
any major mode-related hooks are executed twice.
---
 lisp/textmodes/mhtml-mode.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/textmodes/mhtml-mode.el b/lisp/textmodes/mhtml-mode.el
index 0b5c6756ab9..e2de6959dc6 100644
--- a/lisp/textmodes/mhtml-mode.el
+++ b/lisp/textmodes/mhtml-mode.el
@@ -359,7 +359,7 @@ mhtml-mode
   (add-hook 'before-change-functions #'c-foreign-truncate-lit-pos-cache nil t)
 
   ;; This is sort of a prog-mode as well as a text mode.
-  (run-hooks 'prog-mode-hook))
+  (run-mode-hooks 'prog-mode-hook))
 
 (put 'mhtml-mode 'flyspell-mode-predicate #'mhtml--flyspell-check-word)
 
-- 
2.44.0

-- 
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>