Skip to content

Commit

Permalink
Use save-mark-and-excursion in query-replace-read-args (bug#45617)
Browse files Browse the repository at this point in the history
  • Loading branch information
link0ff committed Jan 29, 2021
1 parent 4ce5646 commit 840b1c6
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lisp/replace.el
Expand Up @@ -343,14 +343,15 @@ Prompt with PROMPT. REGEXP-FLAG non-nil means the response should a regexp."
(defun query-replace-read-args (prompt regexp-flag &optional noerror)
(unless noerror
(barf-if-buffer-read-only))
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(list from to
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from) 'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(and current-prefix-arg (eq current-prefix-arg '-)))))
(save-mark-and-excursion
(let* ((from (query-replace-read-from prompt regexp-flag))
(to (if (consp from) (prog1 (cdr from) (setq from (car from)))
(query-replace-read-to from prompt regexp-flag))))
(list from to
(or (and current-prefix-arg (not (eq current-prefix-arg '-)))
(and (plist-member (text-properties-at 0 from) 'isearch-regexp-function)
(get-text-property 0 'isearch-regexp-function from)))
(and current-prefix-arg (eq current-prefix-arg '-))))))

(defun query-replace (from-string to-string &optional delimited start end backward region-noncontiguous-p)
"Replace some occurrences of FROM-STRING with TO-STRING.
Expand Down

0 comments on commit 840b1c6

Please sign in to comment.