aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBozhidar Batsov <bozhidar@batsov.dev>2026-02-15 18:23:47 +0200
committerBozhidar Batsov <bozhidar@batsov.dev>2026-02-15 18:23:47 +0200
commitac21323e6dffb3d3122358bbcccb93ea39080fa0 (patch)
tree500400d230f82cef08b5a64cba1a899fe24a8b73
parentdd06dfd912656d41f2c63066aa8bacb898ddf7a2 (diff)
Filter projectile-replace results through project ignore rulesfeature/1227-replace-respects-ignores
Closes #1227 projectile-replace now intersects the files found by rg/ag/grep with the project's file list from projectile-dir-files, ensuring that files ignored via .projectile or other ignore rules are excluded from replacement. Previously the external search tool's results were used directly, which could include backup files and other ignored entries.
-rw-r--r--projectile.el9
1 files changed, 7 insertions, 2 deletions
diff --git a/projectile.el b/projectile.el
index 6c5306b..c7e21c6 100644
--- a/projectile.el
+++ b/projectile.el
@@ -4970,8 +4970,13 @@ on which to run the replacement."
(new-text (read-string
(projectile-prepend-project-name
(format "Replace %s with: " old-text))))
- (files (projectile-files-with-string old-text directory file-ext)))
- (fileloop-initialize-replace (regexp-quote old-text) new-text files 'default)
+ (files (projectile-files-with-string old-text directory file-ext))
+ ;; Filter results through the project's file list so that files
+ ;; ignored via .projectile or other ignore rules are excluded.
+ (project-files (mapcar (lambda (file) (expand-file-name file directory))
+ (projectile-dir-files directory)))
+ (filtered-files (seq-filter (lambda (f) (member f project-files)) files)))
+ (fileloop-initialize-replace (regexp-quote old-text) new-text filtered-files 'default)
(fileloop-continue)))
;;;###autoload