summaryrefslogtreecommitdiff
path: root/lisp/progmodes/executable.el
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-03-03 15:43:35 +0100
committerLars Ingebrigtsen <larsi@gnus.org>2022-03-03 15:43:35 +0100
commitb6587090bfa192efc4db5ac181a9dfd5ee8c0c08 (patch)
treee40fdb1bee6a4b00afe8463d6478650826eb8d19 /lisp/progmodes/executable.el
parentd72cd4a2b761d325e5bb3e664781a4c9001eb2c2 (diff)
downloademacs-b6587090bfa192efc4db5ac181a9dfd5ee8c0c08.tar.gz
Fix clobbering of match data in executable-set-magic
* lisp/progmodes/executable.el (executable-set-magic): Switching buffers may clobber match data, so save the match data first (bug#54218).
Diffstat (limited to 'lisp/progmodes/executable.el')
-rw-r--r--lisp/progmodes/executable.el13
1 files changed, 7 insertions, 6 deletions
diff --git a/lisp/progmodes/executable.el b/lisp/progmodes/executable.el
index d7c093444ed..670b6e7e898 100644
--- a/lisp/progmodes/executable.el
+++ b/lisp/progmodes/executable.el
@@ -240,12 +240,13 @@ executable."
(not (string= argument
(buffer-substring (point) (match-end 1))))
(if (or (not executable-query) no-query-flag
- (save-window-excursion
- ;; Make buffer visible before question.
- (switch-to-buffer (current-buffer))
- (y-or-n-p (format-message
- "Replace magic number by `#!%s'? "
- argument))))
+ (save-match-data
+ (save-window-excursion
+ ;; Make buffer visible before question.
+ (switch-to-buffer (current-buffer))
+ (y-or-n-p (format-message
+ "Replace magic number by `#!%s'? "
+ argument)))))
(progn
(replace-match argument t t nil 1)
(message "Magic number changed to `#!%s'" argument))))