diff options
author | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-06-13 14:16:44 +0100 |
---|---|---|
committer | Aryadev Chavali <aryadev@aryadevchavali.com> | 2024-06-13 14:16:44 +0100 |
commit | adcd05f2b7e25d0a087e08db86d54235e27596a6 (patch) | |
tree | f4de09010f09199a196505a0b5556d34b812e5f7 /Emacs/.config | |
parent | 991104c9a35c9034a90e21b51302a1b8cff9793d (diff) | |
download | dotfiles-adcd05f2b7e25d0a087e08db86d54235e27596a6.tar.gz dotfiles-adcd05f2b7e25d0a087e08db86d54235e27596a6.tar.bz2 dotfiles-adcd05f2b7e25d0a087e08db86d54235e27596a6.zip |
(Emacs/elisp)~search/find-file can now open swiper in new buffer
If some universal argument is given to +search/find-file then after
opening the file it'll open swiper. This reduces keystrokes and makes
it easier to get to somewhere.
Diffstat (limited to 'Emacs/.config')
-rw-r--r-- | Emacs/.config/emacs/elisp/search.el | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Emacs/.config/emacs/elisp/search.el b/Emacs/.config/emacs/elisp/search.el index 1184c20..6336540 100644 --- a/Emacs/.config/emacs/elisp/search.el +++ b/Emacs/.config/emacs/elisp/search.el @@ -24,6 +24,8 @@ ;;; 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.") @@ -46,13 +48,12 @@ Returns a list of files with the directory preprended to them." (+search/get-candidates (expand-file-name directory))) +search/directories))) -(defun +search/find-file () - (interactive) - (find-file - (completing-read "Find file: " - (+search/get-all-candidates) - nil - t))) +(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/search-all () (interactive) |