aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuri Linkov2008-07-23 01:18:39 +0000
committerJuri Linkov2008-07-23 01:18:39 +0000
commitb591f3387a5b01d0419a5263cdba88193cdde0db (patch)
treeaeab1149d8282e4705f9808d0e4492872a887435
parent4542adfb1f4138bf355eb8c90d655023375064b1 (diff)
downloademacs-b591f3387a5b01d0419a5263cdba88193cdde0db.tar.gz
emacs-b591f3387a5b01d0419a5263cdba88193cdde0db.zip
(multi-query-replace-map): New variable.
(perform-replace): Add processing of new multi-buffer keys bound to `automatic-all' and `exit-current'. Set `query-flag' to nil if last input char was `automatic-all'. Set new local variable `multi-buffer' to t when one of new two keys were typed. Return non-nil value of `multi-buffer' that tells to calling functions to continue replacement on the next file.
-rw-r--r--lisp/replace.el29
1 files changed, 26 insertions, 3 deletions
diff --git a/lisp/replace.el b/lisp/replace.el
index 8a83ca62b31..2572125b052 100644
--- a/lisp/replace.el
+++ b/lisp/replace.el
@@ -1372,6 +1372,20 @@ The valid answers include `act', `skip', `act-and-show',
1372`exit', `act-and-exit', `edit', `delete-and-edit', `recenter', 1372`exit', `act-and-exit', `edit', `delete-and-edit', `recenter',
1373`automatic', `backup', `exit-prefix', and `help'.") 1373`automatic', `backup', `exit-prefix', and `help'.")
1374 1374
1375(defvar multi-query-replace-map
1376 (let ((map (make-sparse-keymap)))
1377 (set-keymap-parent map query-replace-map)
1378 (define-key map "Y" 'automatic-all)
1379 (define-key map "N" 'exit-current)
1380 map)
1381 "Keymap that defines additional bindings for multi-buffer replacements.
1382It extends its parent map `query-replace-map' with new bindings to
1383operate on a set of buffers/files. The difference with its parent map
1384is the additional answers `automatic-all' to replace all remaining
1385matches in all remaining buffers with no more questions, and
1386`exit-current' to skip remaining matches in the current buffer
1387and to continue with the next buffer in the sequence.")
1388
1375(defun replace-match-string-symbols (n) 1389(defun replace-match-string-symbols (n)
1376 "Process a list (and any sub-lists), expanding certain symbols. 1390 "Process a list (and any sub-lists), expanding certain symbols.
1377Symbol Expands To 1391Symbol Expands To
@@ -1527,6 +1541,7 @@ make, or the user didn't cancel the call."
1527 (stack nil) 1541 (stack nil)
1528 (replace-count 0) 1542 (replace-count 0)
1529 (nonempty-match nil) 1543 (nonempty-match nil)
1544 (multi-buffer nil)
1530 1545
1531 ;; If non-nil, it is marker saying where in the buffer to stop. 1546 ;; If non-nil, it is marker saying where in the buffer to stop.
1532 (limit nil) 1547 (limit nil)
@@ -1548,6 +1563,11 @@ make, or the user didn't cancel the call."
1548 (goto-char (min start end)) 1563 (goto-char (min start end))
1549 (deactivate-mark)) 1564 (deactivate-mark))
1550 1565
1566 ;; If last typed key in previous call of multi-buffer perform-replace
1567 ;; was `automatic-all', don't ask more questions in next files
1568 (when (eq (lookup-key map (vector last-input-char)) 'automatic-all)
1569 (setq query-flag nil multi-buffer t))
1570
1551 ;; REPLACEMENTS is either a string, a list of strings, or a cons cell 1571 ;; REPLACEMENTS is either a string, a list of strings, or a cons cell
1552 ;; containing a function and its first argument. The function is 1572 ;; containing a function and its first argument. The function is
1553 ;; called to generate each replacement like this: 1573 ;; called to generate each replacement like this:
@@ -1705,6 +1725,8 @@ make, or the user didn't cancel the call."
1705 ((eq def 'exit) 1725 ((eq def 'exit)
1706 (setq keep-going nil) 1726 (setq keep-going nil)
1707 (setq done t)) 1727 (setq done t))
1728 ((eq def 'exit-current)
1729 (setq multi-buffer t keep-going nil done t))
1708 ((eq def 'backup) 1730 ((eq def 'backup)
1709 (if stack 1731 (if stack
1710 (let ((elt (pop stack))) 1732 (let ((elt (pop stack)))
@@ -1744,14 +1766,15 @@ make, or the user didn't cancel the call."
1744 real-match-data (replace-match-data 1766 real-match-data (replace-match-data
1745 t real-match-data) 1767 t real-match-data)
1746 replaced t))) 1768 replaced t)))
1747 ((eq def 'automatic) 1769 ((or (eq def 'automatic) (eq def 'automatic-all))
1748 (or replaced 1770 (or replaced
1749 (setq noedit 1771 (setq noedit
1750 (replace-match-maybe-edit 1772 (replace-match-maybe-edit
1751 next-replacement nocasify literal 1773 next-replacement nocasify literal
1752 noedit real-match-data) 1774 noedit real-match-data)
1753 replace-count (1+ replace-count))) 1775 replace-count (1+ replace-count)))
1754 (setq done t query-flag nil replaced t)) 1776 (setq done t query-flag nil replaced t)
1777 (if (eq def 'automatic-all) (setq multi-buffer t)))
1755 ((eq def 'skip) 1778 ((eq def 'skip)
1756 (setq done t)) 1779 (setq done t))
1757 ((eq def 'recenter) 1780 ((eq def 'recenter)
@@ -1838,7 +1861,7 @@ make, or the user didn't cancel the call."
1838 (message "Replaced %d occurrence%s" 1861 (message "Replaced %d occurrence%s"
1839 replace-count 1862 replace-count
1840 (if (= replace-count 1) "" "s"))) 1863 (if (= replace-count 1) "" "s")))
1841 (and keep-going stack))) 1864 (or (and keep-going stack) multi-buffer)))
1842 1865
1843(defvar replace-overlay nil) 1866(defvar replace-overlay nil)
1844 1867