diff options
| author | Glenn Morris | 2020-05-06 09:28:36 -0700 |
|---|---|---|
| committer | Glenn Morris | 2020-05-06 09:28:36 -0700 |
| commit | e292097f55126ca2f42404f4c5c6ec7ddb62078b (patch) | |
| tree | ee4301d67ce3f2d6e65280a0e0cc91070f0c0bcf /lisp/fileloop.el | |
| parent | 29171c3a8c4dcd1f740df84c759397b6ffef68ee (diff) | |
| parent | 4b419083f92dc4b4313ae0d9991b825331c2f651 (diff) | |
| download | emacs-e292097f55126ca2f42404f4c5c6ec7ddb62078b.tar.gz emacs-e292097f55126ca2f42404f4c5c6ec7ddb62078b.zip | |
Merge from origin/emacs-27
4b419083f9 Honor search-upper-case
310112fdc7 Fix eww-follow-link on URLs with #target
# Conflicts:
# lisp/fileloop.el
Diffstat (limited to 'lisp/fileloop.el')
| -rw-r--r-- | lisp/fileloop.el | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/lisp/fileloop.el b/lisp/fileloop.el index 8f4911638e9..d52e35d886f 100644 --- a/lisp/fileloop.el +++ b/lisp/fileloop.el | |||
| @@ -181,8 +181,7 @@ operating on the next file and nil otherwise." | |||
| 181 | (fileloop-initialize | 181 | (fileloop-initialize |
| 182 | files | 182 | files |
| 183 | (lambda () | 183 | (lambda () |
| 184 | (let ((case-fold-search | 184 | (let ((case-fold-search (fileloop--case-fold regexp case-fold))) |
| 185 | (if (memq case-fold '(t nil)) case-fold case-fold-search))) | ||
| 186 | (re-search-forward regexp nil t))) | 185 | (re-search-forward regexp nil t))) |
| 187 | (lambda () | 186 | (lambda () |
| 188 | (unless (eq last-buffer (current-buffer)) | 187 | (unless (eq last-buffer (current-buffer)) |
| @@ -190,13 +189,27 @@ operating on the next file and nil otherwise." | |||
| 190 | (message "Scanning file %s...found" buffer-file-name)) | 189 | (message "Scanning file %s...found" buffer-file-name)) |
| 191 | nil)))) | 190 | nil)))) |
| 192 | 191 | ||
| 192 | (defun fileloop--case-fold (regexp case-fold) | ||
| 193 | (let ((value | ||
| 194 | (if (memql case-fold '(nil t)) | ||
| 195 | case-fold | ||
| 196 | case-fold-search))) | ||
| 197 | (if (and value search-upper-case) | ||
| 198 | (isearch-no-upper-case-p regexp t) | ||
| 199 | value))) | ||
| 200 | |||
| 193 | ;;;###autoload | 201 | ;;;###autoload |
| 194 | (defun fileloop-initialize-replace (from to files case-fold &optional delimited) | 202 | (defun fileloop-initialize-replace (from to files case-fold &optional delimited) |
| 195 | "Initialize a new round of query&replace on several files. | 203 | "Initialize a new round of query&replace on several files. |
| 196 | FROM is a regexp and TO is the replacement to use. | 204 | FROM is a regexp and TO is the replacement to use. |
| 197 | FILES describes the file, as in `fileloop-initialize'. | 205 | FILES describes the files, as in `fileloop-initialize'. |
| 198 | CASE-FOLD can be t, nil, or `default', the latter one meaning to obey | 206 | CASE-FOLD can be t, nil, or `default': |
| 199 | the default setting of `case-fold-search'. | 207 | if it is nil, matching of FROM is case-sensitive. |
| 208 | if it is t, matching of FROM is case-insensitive, except | ||
| 209 | when `search-upper-case' is non-nil and FROM includes | ||
| 210 | upper-case letters. | ||
| 211 | if it is `default', the function uses the value of | ||
| 212 | `case-fold-search' instead. | ||
| 200 | DELIMITED if non-nil means replace only word-delimited matches." | 213 | DELIMITED if non-nil means replace only word-delimited matches." |
| 201 | ;; FIXME: Not sure how the delimited-flag interacts with the regexp-flag in | 214 | ;; FIXME: Not sure how the delimited-flag interacts with the regexp-flag in |
| 202 | ;; `perform-replace', so I just try to mimic the old code. | 215 | ;; `perform-replace', so I just try to mimic the old code. |
| @@ -204,8 +217,7 @@ DELIMITED if non-nil means replace only word-delimited matches." | |||
| 204 | (fileloop-initialize | 217 | (fileloop-initialize |
| 205 | files | 218 | files |
| 206 | (lambda () | 219 | (lambda () |
| 207 | (let ((case-fold-search | 220 | (let ((case-fold-search (fileloop--case-fold from case-fold))) |
| 208 | (if (memql case-fold '(nil t)) case-fold case-fold-search))) | ||
| 209 | (when (re-search-forward from nil t) | 221 | (when (re-search-forward from nil t) |
| 210 | ;; When we find a match, save its beginning for | 222 | ;; When we find a match, save its beginning for |
| 211 | ;; `perform-replace' (we used to just set point, but this | 223 | ;; `perform-replace' (we used to just set point, but this |
| @@ -213,9 +225,10 @@ DELIMITED if non-nil means replace only word-delimited matches." | |||
| 213 | ;; `switch-to-buffer-preserve-window-point'). | 225 | ;; `switch-to-buffer-preserve-window-point'). |
| 214 | (puthash (current-buffer) (match-beginning 0) mstart)))) | 226 | (puthash (current-buffer) (match-beginning 0) mstart)))) |
| 215 | (lambda () | 227 | (lambda () |
| 216 | (perform-replace from to t t delimited nil multi-query-replace-map | 228 | (let ((case-fold-search (fileloop--case-fold from case-fold))) |
| 217 | (gethash (current-buffer) mstart (point-min)) | 229 | (perform-replace from to t t delimited nil multi-query-replace-map |
| 218 | (point-max)))))) | 230 | (gethash (current-buffer) mstart (point-min)) |
| 231 | (point-max))))))) | ||
| 219 | 232 | ||
| 220 | (provide 'fileloop) | 233 | (provide 'fileloop) |
| 221 | ;;; fileloop.el ends here | 234 | ;;; fileloop.el ends here |