diff options
| author | Juanma Barranquero | 2011-04-19 15:44:55 +0200 |
|---|---|---|
| committer | Juanma Barranquero | 2011-04-19 15:44:55 +0200 |
| commit | 06b605171f1c9d8b42bd3326a243b8b03d2e4e58 (patch) | |
| tree | e96c135042999136bf0e75d113aae306e51983e3 /lisp/replace.el | |
| parent | 04c569546ad52f6270d8fc6d4aa0750950a0ac05 (diff) | |
| download | emacs-06b605171f1c9d8b42bd3326a243b8b03d2e4e58.tar.gz emacs-06b605171f1c9d8b42bd3326a243b8b03d2e4e58.zip | |
lisp/*.el: Lexical-binding cleanup.
Diffstat (limited to 'lisp/replace.el')
| -rw-r--r-- | lisp/replace.el | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/lisp/replace.el b/lisp/replace.el index 0ed716966ed..31a48d48960 100644 --- a/lisp/replace.el +++ b/lisp/replace.el | |||
| @@ -98,6 +98,10 @@ is highlighted lazily using isearch lazy highlighting (see | |||
| 98 | :group 'matching | 98 | :group 'matching |
| 99 | :version "22.1") | 99 | :version "22.1") |
| 100 | 100 | ||
| 101 | (defvar replace-count 0 | ||
| 102 | "Number of replacements done so far. | ||
| 103 | See `replace-regexp' and `query-replace-regexp-eval'.") | ||
| 104 | |||
| 101 | (defun query-replace-descr (string) | 105 | (defun query-replace-descr (string) |
| 102 | (mapconcat 'isearch-text-char-description string "")) | 106 | (mapconcat 'isearch-text-char-description string "")) |
| 103 | 107 | ||
| @@ -849,7 +853,7 @@ Alternatively, click \\[occur-mode-mouse-goto] on an item to go to it. | |||
| 849 | (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) | 853 | (add-hook 'change-major-mode-hook 'font-lock-defontify nil t) |
| 850 | (setq next-error-function 'occur-next-error)) | 854 | (setq next-error-function 'occur-next-error)) |
| 851 | 855 | ||
| 852 | (defun occur-revert-function (ignore1 ignore2) | 856 | (defun occur-revert-function (_ignore1 _ignore2) |
| 853 | "Handle `revert-buffer' for Occur mode buffers." | 857 | "Handle `revert-buffer' for Occur mode buffers." |
| 854 | (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))) | 858 | (apply 'occur-1 (append occur-revert-arguments (list (buffer-name))))) |
| 855 | 859 | ||
| @@ -1069,6 +1073,8 @@ are not modified." | |||
| 1069 | (interactive (occur-read-primary-args)) | 1073 | (interactive (occur-read-primary-args)) |
| 1070 | (occur-1 regexp nlines (list (current-buffer)))) | 1074 | (occur-1 regexp nlines (list (current-buffer)))) |
| 1071 | 1075 | ||
| 1076 | (defvar ido-ignore-item-temp-list) | ||
| 1077 | |||
| 1072 | (defun multi-occur (bufs regexp &optional nlines) | 1078 | (defun multi-occur (bufs regexp &optional nlines) |
| 1073 | "Show all lines in buffers BUFS containing a match for REGEXP. | 1079 | "Show all lines in buffers BUFS containing a match for REGEXP. |
| 1074 | This function acts on multiple buffers; otherwise, it is exactly like | 1080 | This function acts on multiple buffers; otherwise, it is exactly like |
| @@ -1204,11 +1210,12 @@ See also `multi-occur'." | |||
| 1204 | (set-buffer-modified-p nil) | 1210 | (set-buffer-modified-p nil) |
| 1205 | (run-hooks 'occur-hook))))))) | 1211 | (run-hooks 'occur-hook))))))) |
| 1206 | 1212 | ||
| 1207 | (defun occur-engine (regexp buffers out-buf nlines case-fold-search | 1213 | (defun occur-engine (regexp buffers out-buf nlines case-fold |
| 1208 | title-face prefix-face match-face keep-props) | 1214 | title-face prefix-face match-face keep-props) |
| 1209 | (with-current-buffer out-buf | 1215 | (with-current-buffer out-buf |
| 1210 | (let ((globalcount 0) | 1216 | (let ((globalcount 0) |
| 1211 | (coding nil)) | 1217 | (coding nil) |
| 1218 | (case-fold-search case-fold)) | ||
| 1212 | ;; Map over all the buffers | 1219 | ;; Map over all the buffers |
| 1213 | (dolist (buf buffers) | 1220 | (dolist (buf buffers) |
| 1214 | (when (buffer-live-p buf) | 1221 | (when (buffer-live-p buf) |
| @@ -1308,8 +1315,7 @@ See also `multi-occur'." | |||
| 1308 | (nth 0 ret)))) | 1315 | (nth 0 ret)))) |
| 1309 | ;; Actually insert the match display data | 1316 | ;; Actually insert the match display data |
| 1310 | (with-current-buffer out-buf | 1317 | (with-current-buffer out-buf |
| 1311 | (let ((beg (point)) | 1318 | (insert data))) |
| 1312 | (end (progn (insert data) (point))))))) | ||
| 1313 | (goto-char endpt)) | 1319 | (goto-char endpt)) |
| 1314 | (if endpt | 1320 | (if endpt |
| 1315 | (progn | 1321 | (progn |
| @@ -1557,8 +1563,9 @@ type them using Lisp syntax." | |||
| 1557 | (setcar n 'replace-count)))))) | 1563 | (setcar n 'replace-count)))))) |
| 1558 | (setq n (cdr n)))) | 1564 | (setq n (cdr n)))) |
| 1559 | 1565 | ||
| 1560 | (defun replace-eval-replacement (expression replace-count) | 1566 | (defun replace-eval-replacement (expression count) |
| 1561 | (let ((replacement (eval expression))) | 1567 | (let* ((replace-count count) |
| 1568 | (replacement (eval expression))) | ||
| 1562 | (if (stringp replacement) | 1569 | (if (stringp replacement) |
| 1563 | replacement | 1570 | replacement |
| 1564 | (prin1-to-string replacement t)))) | 1571 | (prin1-to-string replacement t)))) |
| @@ -1578,15 +1585,15 @@ with the `noescape' argument set. | |||
| 1578 | (prin1-to-string replacement t)) | 1585 | (prin1-to-string replacement t)) |
| 1579 | t t))) | 1586 | t t))) |
| 1580 | 1587 | ||
| 1581 | (defun replace-loop-through-replacements (data replace-count) | 1588 | (defun replace-loop-through-replacements (data count) |
| 1582 | ;; DATA is a vector contaning the following values: | 1589 | ;; DATA is a vector contaning the following values: |
| 1583 | ;; 0 next-rotate-count | 1590 | ;; 0 next-rotate-count |
| 1584 | ;; 1 repeat-count | 1591 | ;; 1 repeat-count |
| 1585 | ;; 2 next-replacement | 1592 | ;; 2 next-replacement |
| 1586 | ;; 3 replacements | 1593 | ;; 3 replacements |
| 1587 | (if (= (aref data 0) replace-count) | 1594 | (if (= (aref data 0) count) |
| 1588 | (progn | 1595 | (progn |
| 1589 | (aset data 0 (+ replace-count (aref data 1))) | 1596 | (aset data 0 (+ count (aref data 1))) |
| 1590 | (let ((next (cdr (aref data 2)))) | 1597 | (let ((next (cdr (aref data 2)))) |
| 1591 | (aset data 2 (if (consp next) next (aref data 3)))))) | 1598 | (aset data 2 (if (consp next) next (aref data 3)))))) |
| 1592 | (car (aref data 2))) | 1599 | (car (aref data 2))) |
| @@ -2011,6 +2018,11 @@ make, or the user didn't cancel the call." | |||
| 2011 | (if (= replace-count 1) "" "s"))) | 2018 | (if (= replace-count 1) "" "s"))) |
| 2012 | (or (and keep-going stack) multi-buffer))) | 2019 | (or (and keep-going stack) multi-buffer))) |
| 2013 | 2020 | ||
| 2021 | (defvar isearch-error) | ||
| 2022 | (defvar isearch-forward) | ||
| 2023 | (defvar isearch-case-fold-search) | ||
| 2024 | (defvar isearch-string) | ||
| 2025 | |||
| 2014 | (defvar replace-overlay nil) | 2026 | (defvar replace-overlay nil) |
| 2015 | 2027 | ||
| 2016 | (defun replace-highlight (match-beg match-end range-beg range-end | 2028 | (defun replace-highlight (match-beg match-end range-beg range-end |