From adcd05f2b7e25d0a087e08db86d54235e27596a6 Mon Sep 17 00:00:00 2001 From: Aryadev Chavali Date: Thu, 13 Jun 2024 14:16:44 +0100 Subject: (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. --- Emacs/.config/emacs/elisp/search.el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'Emacs') 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) -- cgit v1.2.3-13-gbd6f