[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 8fc5001ba5b 1/2: (asm-mode): Fix bug#75542
From: |
Stefan Monnier |
Subject: |
master 8fc5001ba5b 1/2: (asm-mode): Fix bug#75542 |
Date: |
Thu, 16 Jan 2025 17:48:30 -0500 (EST) |
branch: master
commit 8fc5001ba5bc9fef3c438a070c87059fc19146a4
Author: Stefan Monnier <monnier@iro.umontreal.ca>
Commit: Stefan Monnier <monnier@iro.umontreal.ca>
(asm-mode): Fix bug#75542
* lisp/progmodes/asm-mode.el (asm-mode): Be careful not to override
changes in the mode map or in `comment-start`.
Move the use of `asm-mode-set-comment-hook` back to where it was before
commit 0cff4e67f1de.
(asm-mode-set-comment-hook): Declare it obsolete.
---
etc/NEWS | 5 +++++
lisp/progmodes/asm-mode.el | 24 +++++++++++++-----------
2 files changed, 18 insertions(+), 11 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index 4c84919678c..5d056711ebd 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -333,6 +333,11 @@ modal editing packages.
* Changes in Specialized Modes and Packages in Emacs 31.1
+---
+** ASM mode
+*** 'asm-mode-set-comment-hook' is obsolete.
+You can now set `asm-comment-char' from 'asm-mode-hook' instead.
+
---
** Ibuffer
*** New column 'recency' in Ibuffer display.
diff --git a/lisp/progmodes/asm-mode.el b/lisp/progmodes/asm-mode.el
index a2334505db9..2d1c645f42c 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 @@
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 @@ Features a private abbrev table and the following bindings:
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,15 +124,18 @@ Special commands:
\\{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))
- (local-set-key (vector asm-comment-char) #'asm-comment)
+ ;; FIXME: Use `post-self-insert-hook' instead and make it conditional
+ ;; on some "electricity" config var.
+ (unless (lookup-key asm-mode-map (vector asm-comment-char))
+ (use-local-map (make-composed-keymap nil asm-mode-map))
+ (local-set-key (vector asm-comment-char) #'asm-comment))
(set-syntax-table (make-syntax-table asm-mode-syntax-table))
(modify-syntax-entry asm-comment-char "< b")
- (setq-local comment-start (string asm-comment-char)))
+ (unless (local-variable-p 'comment-start)
+ (setq-local comment-start (string asm-comment-char))))
(setq local-abbrev-table asm-mode-abbrev-table)
(setq-local font-lock-defaults '(asm-font-lock-keywords))
@@ -143,6 +143,8 @@ Special commands:
;; 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>\\|\\*+/\\)")