GNU bug report logs -
#75542
31.0.50; asm-mode runs hooks in wrong order since d8e209 (1 Dec 2024).
Previous Next
Reported by: David Koppelman <koppel <at> ece.lsu.edu>
Date: Mon, 13 Jan 2025 21:41:01 UTC
Severity: normal
Found in version 31.0.50
Done: Stefan Monnier <monnier <at> iro.umontreal.ca>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
> The order in which asm-mode runs its two hooks, asm-mode-hook and
> asm-mode-set-comment-hook, changed with commit
> 676ff9fd7c083598b2955a463774283768d8e209 (1 December 2024).
>
> The comments near the top of asm-mode.el explain that
> asm-mode-set-comment-hook hooks should be run before those on
> asm-mode-hook.
Indeed, I now see that the above commit has rendered
`asm-mode-set-comment-hook` redundant, you can now do the same from
`asm-mode-hook`.
Could you describe how/why the different order affected your setup?
> The correct behavior can be restored (for me) by removing the
> :after-hook attribute in the asm-mode definition (which makes the code
> that follows the body argument of define-derived-mode). I don't know
> whether that is the right fix.
That would defeat the purpose of that commit (which was to fix bug#74447).
I'd suggest the patch below instead, which also marks
`asm-mode-set-comment-hook` as obsolete.
Stefan
diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
index a2334505db9..b2a9df45140 100644
--- a/lisp/progmodes/asm-mode.el
+++ b/lisp/progmodes/asm-mode.el
@@ -40,10 +40,7 @@
;;
;; Code is indented to the first tab stop level.
-;; This mode runs two hooks:
-;; 1) `asm-mode-set-comment-hook' before the part of the initialization
-;; depending on `asm-comment-char', and
-;; 2) `asm-mode-hook' at the end of initialization.
+;; This mode runs the hook `asm-mode-hook' at the end of initialization.
;;; Code:
@@ -105,6 +102,8 @@ asm-font-lock-keywords
cpp-font-lock-keywords)
"Additional expressions to highlight in Assembler mode.")
+(make-obsolete-variable 'asm-mode-set-comment-hook 'asm-mode-hook "31.0")
+
;;;###autoload
(define-derived-mode asm-mode prog-mode "Assembler"
"Major mode for editing typical assembler code.
@@ -117,9 +116,7 @@ asm-mode
The character used for making comments is set by the variable
`asm-comment-char' (which defaults to `?\\;').
-
-Alternatively, you may set this variable in `asm-mode-set-comment-hook',
-which is called near the beginning of mode initialization.
+Alternatively, you may set this variable in `asm-mode-hook'.
Turning on Asm mode runs the hook `asm-mode-hook' at the end of initialization.
@@ -127,7 +124,6 @@ asm-mode
\\{asm-mode-map}"
:after-hook
(progn
- (run-hooks 'asm-mode-set-comment-hook)
;; Make our own local child of `asm-mode-map'
;; so we can define our own comment character.
(use-local-map (make-composed-keymap nil asm-mode-map))
@@ -143,6 +139,8 @@ asm-mode
;; Stay closer to the old TAB behavior (was tab-to-tab-stop).
(setq-local tab-always-indent nil)
+ (run-hooks 'asm-mode-set-comment-hook)
+
(setq-local comment-add 1)
(setq-local comment-start-skip "\\(?:\\s<+\\|/[/*]+\\)[ \t]*")
(setq-local comment-end-skip "[ \t]*\\(\\s>\\|\\*+/\\)")
This bug report was last modified 129 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.