GNU bug report logs - #75542
31.0.50; asm-mode runs hooks in wrong order since d8e209 (1 Dec 2024).

Previous Next

Package: emacs;

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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75542 in the body.
You can then email your comments to 75542 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#75542; Package emacs. (Mon, 13 Jan 2025 21:41:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Koppelman <koppel <at> ece.lsu.edu>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Mon, 13 Jan 2025 21:41:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: David Koppelman <koppel <at> ece.lsu.edu>
To: bug-gnu-emacs <at> gnu.org
Subject: 31.0.50; asm-mode runs hooks in wrong order since d8e209 (1 Dec 2024).
Date: Mon, 13 Jan 2025 15:39:54 -0600
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.

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.

diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
index a2334505db9..c8e82d707a6 100644
--- a/lisp/progmodes/asm-mode.el
+++ b/lisp/progmodes/asm-mode.el
@@ -125,7 +125,6 @@ asm-mode
 
 Special commands:
 \\{asm-mode-map}"
-  :after-hook
   (progn
     (run-hooks 'asm-mode-set-comment-hook)
     ;; Make our own local child of `asm-mode-map'




In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 2.24.33, cairo version 1.17.4) of 2025-01-06 built on cyc2.ece.lsu.edu
Repository revision: c3ec174a6c2d1118e82aecceb203634f7b567e20
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Red Hat Enterprise Linux 9.4 (Plow)

Configured using:
 'configure 'CFLAGS=-O2 -march=native' --without-pop
 --with-native-compilation'

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK2 ZLIB

Important settings:
  value of $LC_COLLATE: C
  value of $LC_TIME: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: ELisp/l

Minor modes in effect:
  bug-reference-prog-mode: t
  global-hi-lock-mode: t
  hi-lock-mode: t
  which-function-mode: t
  flyspell-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  minibuffer-regexp-mode: t
  column-number-mode: t
  line-number-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75542; Package emacs. (Mon, 13 Jan 2025 22:08:02 GMT) Full text and rfc822 format available.

Message #8 received at 75542 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Kangas <stefankangas <at> gmail.com>
To: David Koppelman <koppel <at> ece.lsu.edu>, 75542 <at> debbugs.gnu.org
Cc: Stefan Monnier <monnier <at> iro.umontreal.ca>
Subject: Re: bug#75542: 31.0.50; asm-mode runs hooks in wrong order since
 d8e209 (1 Dec 2024).
Date: Mon, 13 Jan 2025 22:07:16 +0000
David Koppelman <koppel <at> ece.lsu.edu> writes:

> 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.
>
> 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.

I'm copying in Stefan Monnier.

> diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
> index a2334505db9..c8e82d707a6 100644
> --- a/lisp/progmodes/asm-mode.el
> +++ b/lisp/progmodes/asm-mode.el
> @@ -125,7 +125,6 @@ asm-mode
>
>  Special commands:
>  \\{asm-mode-map}"
> -  :after-hook
>    (progn
>      (run-hooks 'asm-mode-set-comment-hook)
>      ;; Make our own local child of `asm-mode-map'
>
>
>
>
> In GNU Emacs 31.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
>  2.24.33, cairo version 1.17.4) of 2025-01-06 built on cyc2.ece.lsu.edu
> Repository revision: c3ec174a6c2d1118e82aecceb203634f7b567e20
> Repository branch: master
> Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
> System Description: Red Hat Enterprise Linux 9.4 (Plow)
>
> Configured using:
>  'configure 'CFLAGS=-O2 -march=native' --without-pop
>  --with-native-compilation'
>
> Configured features:
> ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
> LCMS2 LIBSELINUX LIBSYSTEMD LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY
> PDUMPER PNG RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS
> TREE_SITTER WEBP X11 XDBE XIM XINPUT2 XPM GTK2 ZLIB
>
> Important settings:
>   value of $LC_COLLATE: C
>   value of $LC_TIME: C
>   value of $LANG: en_US.UTF-8
>   locale-coding-system: utf-8-unix
>
> Major mode: ELisp/l
>
> Minor modes in effect:
>   bug-reference-prog-mode: t
>   global-hi-lock-mode: t
>   hi-lock-mode: t
>   which-function-mode: t
>   flyspell-mode: t
>   tooltip-mode: t
>   global-eldoc-mode: t
>   eldoc-mode: t
>   show-paren-mode: t
>   mouse-wheel-mode: t
>   file-name-shadow-mode: t
>   global-font-lock-mode: t
>   font-lock-mode: t
>   minibuffer-regexp-mode: t
>   column-number-mode: t
>   line-number-mode: t
>   transient-mark-mode: t
>   auto-composition-mode: t
>   auto-encryption-mode: t
>   auto-compression-mode: t




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#75542; Package emacs. (Tue, 14 Jan 2025 22:42:01 GMT) Full text and rfc822 format available.

Message #11 received at 75542 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: David Koppelman <koppel <at> ece.lsu.edu>
Cc: 75542 <at> debbugs.gnu.org
Subject: Re: bug#75542: 31.0.50; asm-mode runs hooks in wrong order since
 d8e209 (1 Dec 2024).
Date: Tue, 14 Jan 2025 17:41:02 -0500
> 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>\\|\\*+/\\)")





bug closed, send any further explanations to 75542 <at> debbugs.gnu.org and David Koppelman <koppel <at> ece.lsu.edu> Request was from Stefan Monnier <monnier <at> iro.umontreal.ca> to control <at> debbugs.gnu.org. (Thu, 16 Jan 2025 22:30:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 14 Feb 2025 12:24:14 GMT) Full text and rfc822 format available.

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.