summaryrefslogtreecommitdiff
path: root/lisp/fileloop.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2020-05-06 09:28:36 -0700
committerGlenn Morris <rgm@gnu.org>2020-05-06 09:28:36 -0700
commite292097f55126ca2f42404f4c5c6ec7ddb62078b (patch)
treeee4301d67ce3f2d6e65280a0e0cc91070f0c0bcf /lisp/fileloop.el
parent29171c3a8c4dcd1f740df84c759397b6ffef68ee (diff)
parent4b419083f92dc4b4313ae0d9991b825331c2f651 (diff)
downloademacs-e292097f55126ca2f42404f4c5c6ec7ddb62078b.tar.gz
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.el33
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."
(fileloop-initialize
files
(lambda ()
- (let ((case-fold-search
- (if (memq case-fold '(t nil)) case-fold case-fold-search)))
+ (let ((case-fold-search (fileloop--case-fold regexp case-fold)))
(re-search-forward regexp nil t)))
(lambda ()
(unless (eq last-buffer (current-buffer))
@@ -190,13 +189,27 @@ operating on the next file and nil otherwise."
(message "Scanning file %s...found" buffer-file-name))
nil))))
+(defun fileloop--case-fold (regexp case-fold)
+ (let ((value
+ (if (memql case-fold '(nil t))
+ case-fold
+ case-fold-search)))
+ (if (and value search-upper-case)
+ (isearch-no-upper-case-p regexp t)
+ value)))
+
;;;###autoload
(defun fileloop-initialize-replace (from to files case-fold &optional delimited)
"Initialize a new round of query&replace on several files.
FROM is a regexp and TO is the replacement to use.
-FILES describes the file, as in `fileloop-initialize'.
-CASE-FOLD can be t, nil, or `default', the latter one meaning to obey
-the default setting of `case-fold-search'.
+FILES describes the files, as in `fileloop-initialize'.
+CASE-FOLD can be t, nil, or `default':
+ if it is nil, matching of FROM is case-sensitive.
+ if it is t, matching of FROM is case-insensitive, except
+ when `search-upper-case' is non-nil and FROM includes
+ upper-case letters.
+ if it is `default', the function uses the value of
+ `case-fold-search' instead.
DELIMITED if non-nil means replace only word-delimited matches."
;; FIXME: Not sure how the delimited-flag interacts with the regexp-flag in
;; `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."
(fileloop-initialize
files
(lambda ()
- (let ((case-fold-search
- (if (memql case-fold '(nil t)) case-fold case-fold-search)))
+ (let ((case-fold-search (fileloop--case-fold from case-fold)))
(when (re-search-forward from nil t)
;; When we find a match, save its beginning for
;; `perform-replace' (we used to just set point, but this
@@ -213,9 +225,10 @@ DELIMITED if non-nil means replace only word-delimited matches."
;; `switch-to-buffer-preserve-window-point').
(puthash (current-buffer) (match-beginning 0) mstart))))
(lambda ()
- (perform-replace from to t t delimited nil multi-query-replace-map
- (gethash (current-buffer) mstart (point-min))
- (point-max))))))
+ (let ((case-fold-search (fileloop--case-fold from case-fold)))
+ (perform-replace from to t t delimited nil multi-query-replace-map
+ (gethash (current-buffer) mstart (point-min))
+ (point-max)))))))
(provide 'fileloop)
;;; fileloop.el ends here