Created
February 27, 2016 12:30
-
-
Save d12frosted/9ceaa3999b42d95f21fd to your computer and use it in GitHub Desktop.
A version of projectile-replace function that works with regexps. Be careful when using it on huge projects.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun projectile-replace-regexp () | |
"Replace a string in the project using `tags-query-replace'. | |
Less efficient than `projectile-replace' but at least allows | |
usage of regular expressions. See | |
https://github.com/bbatsov/projectile/issues/576 for more details | |
on `projectile-replace' issue with regexps." | |
(interactive "P") | |
(let* ((old-text (read-string | |
(projectile-prepend-project-name "Replace: ") | |
(projectile-symbol-or-selection-at-point))) | |
(new-text (read-string | |
(projectile-prepend-project-name | |
(format "Replace %s with: " old-text)))) | |
(files (-map (lambda (f) (concat (projectile-project-root) f)) (projectile-current-project-files)))) | |
(tags-query-replace old-text new-text nil (cons 'list files)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment