From e546a66da017494e460c74a9c7fc750409749851 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 13 Jun 2024 14:18:55 +0100 Subject: (Emacs/elisp)~search-all cleaned up --- Emacs/.config/emacs/elisp/search.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'Emacs/.config/emacs/elisp') diff --git a/Emacs/.config/emacs/elisp/search.el b/Emacs/.config/emacs/elisp/search.el index 6336540..344d92f 100644 --- a/Emacs/.config/emacs/elisp/search.el +++ b/Emacs/.config/emacs/elisp/search.el @@ -55,14 +55,19 @@ Returns a list of files with the directory preprended to them." (if arg (swiper))))) +(defun +search/-format-grep-candidates () + (cl-reduce + #'(lambda (x y) (concat x " " y)) + (mapcar + #'(lambda (x) (concat "\"" x "\"")) + (cl-remove-if #'directory-name-p (+search/get-all-candidates))))) + (defun +search/search-all () (interactive) - (let ((term (read-string "Search for: "))) - (grep (format "grep --color=auto -nH --null -e \"%s\" -- %s" - term - (cl-reduce #'(lambda (x y) (concat x " " y)) - (mapcar #'(lambda (x) (concat "\"" x "\"")) - (cl-remove-if #'directory-name-p (+search/get-all-candidates)))))))) + (let ((format-str "grep --color=auto -nIH --null -e \"%s\" -- %s") + (term (read-string "Search for: ")) + (candidates (+search/-format-grep-candidates))) + (grep (format format-str term candidates)))) (provide 'search) ;;; search.el ends here -- cgit v1.2.3-13-gbd6f