aboutsummaryrefslogtreecommitdiff
path: root/Emacs/.config/emacs/elisp/search.el
diff options
context:
space:
mode:
authorAryadev Chavali <aryadev@aryadevchavali.com>2024-10-01 14:25:07 +0100
committerAryadev Chavali <aryadev@aryadevchavali.com>2024-10-01 16:24:42 +0100
commitb06202b882b0226e9348805838b01997da17eec2 (patch)
tree4161aad817457351a841c03ac042ccf14425f12e /Emacs/.config/emacs/elisp/search.el
parent1bd01d419dbe72c560e46798c22eb5fc40fd7770 (diff)
downloaddotfiles-b06202b882b0226e9348805838b01997da17eec2.tar.gz
dotfiles-b06202b882b0226e9348805838b01997da17eec2.tar.bz2
dotfiles-b06202b882b0226e9348805838b01997da17eec2.zip
(Emacs/config)~Ivy + Counsel -> IComplete + Consult
Decided to use vanilla packages a bit more, and got a bit bored of Ivy + Counsel.
Diffstat (limited to 'Emacs/.config/emacs/elisp/search.el')
-rw-r--r--Emacs/.config/emacs/elisp/search.el25
1 files changed, 12 insertions, 13 deletions
diff --git a/Emacs/.config/emacs/elisp/search.el b/Emacs/.config/emacs/elisp/search.el
index 4b0097c..0afa2b3 100644
--- a/Emacs/.config/emacs/elisp/search.el
+++ b/Emacs/.config/emacs/elisp/search.el
@@ -24,14 +24,12 @@
;;; Code:
-(autoload #'swiper "swiper")
-
(defvar +search/directories
'("~/Dotfiles/" "~/Text/" "~/.local/src/dwm/" "~/.local/src/dwmblocks/" "~/.local/src/st/" "~/Website/")
"List of directories to get candidates from.")
(defun +search/get-candidates (directory)
- "Get files from DIRECTORY using counsel-git-cands.
+ "Get files from DIRECTORY using `git ls-files`.
Returns a list of files with the directory preprended to them."
(let* ((default-directory directory)
(names (split-string
@@ -48,25 +46,26 @@ Returns a list of files with the directory preprended to them."
(+search/get-candidates (expand-file-name directory)))
+search/directories)))
-(defun +search/find-file (&optional arg)
- (interactive "P")
- (let ((file-name (completing-read "Find file: " (+search/get-all-candidates) nil t)))
- (with-current-buffer (find-file file-name)
- (if arg
- (swiper)))))
+(defun +search/find-file ()
+ (interactive)
+ (find-file (completing-read "Find file: " (+search/get-all-candidates) nil t)))
(defun +search/-format-grep-candidates ()
(string-join
(mapcar
- #'(lambda (x) (concat "\"" x "\""))
+ #'(lambda (x) (concat "\"" x "\" "))
(cl-remove-if #'directory-name-p (+search/get-all-candidates)))))
+(autoload #'grep "grep")
+
(defun +search/search-all ()
(interactive)
- (let ((format-str "grep --color=auto -nIH --null -e \"%s\" -- %s")
- (term (read-string "Search for: "))
+ (let ((term (read-string "Search for: "))
(candidates (+search/-format-grep-candidates)))
- (grep (format format-str term candidates))))
+ (grep
+ (format "grep --color=auto -nIHZe \"%s\" -- %s"
+ term candidates))
+ (next-error)))
(provide 'search)
;;; search.el ends here