From dee410617f609530771f94f6f42c429b00ef4a98 Mon Sep 17 00:00:00 2001 From: SqrtMinusOne Date: Fri, 23 Sep 2022 16:32:30 +0300 Subject: [PATCH] feat(emacs): add deadgrep --- .emacs.d/init.el | 16 +++++++++++++++- Emacs.org | 23 ++++++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/.emacs.d/init.el b/.emacs.d/init.el index de8c774..f556098 100644 --- a/.emacs.d/init.el +++ b/.emacs.d/init.el @@ -265,7 +265,8 @@ magit prodigy slime - forge))) + forge + deadgrep))) (use-package avy :straight t @@ -653,6 +654,18 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." (save-place-mode 1) +(defun my/deadgrep-fix-buffer-advice (fun &rest args) + (let ((buf (apply fun args))) + (with-current-buffer buf + (toggle-truncate-lines 1)) + buf)) + +(use-package deadgrep + :straight t + :commands (deadgrep) + :config + (advice-add #'deadgrep--buffer :around #'my/deadgrep-fix-buffer-advice)) + (use-package ivy :straight t :config @@ -724,6 +737,7 @@ then it takes a second \\[keyboard-quit] to abort the minibuffer." "f" 'project-find-file "c" 'counsel-yank-pop "a" 'counsel-rg + "d" 'deadgrep "A" 'counsel-ag) (general-define-key diff --git a/Emacs.org b/Emacs.org index a30b887..e19942b 100644 --- a/Emacs.org +++ b/Emacs.org @@ -490,7 +490,8 @@ Do ex search in other buffer. Like =*=, but switch to other buffer and search th magit prodigy slime - forge))) + forge + deadgrep))) #+end_src *** Avy [[https://github.com/abo-abo/avy][Avy]] is a package that helps navigate Emacs in a tree-like manner. @@ -1100,6 +1101,25 @@ Save the last place visited in the file. #+begin_src emacs-lisp (save-place-mode 1) #+end_src +*** Deadgrep +[[https://github.com/Wilfred/deadgrep][deadgrep]] is a nice Emacs for [[https://github.com/BurntSushi/ripgrep][ripgrep]]. Running =ivy-occur= in =counsel-rg= does something a bit similar, but the deadgrep is much more full-featured. + +Somehow I couldn't hook =toogle-truncate-lines= into the existing hooks, so I add advice. + +#+begin_src emacs-lisp +(defun my/deadgrep-fix-buffer-advice (fun &rest args) + (let ((buf (apply fun args))) + (with-current-buffer buf + (toggle-truncate-lines 1)) + buf)) + +(use-package deadgrep + :straight t + :commands (deadgrep) + :config + (advice-add #'deadgrep--buffer :around #'my/deadgrep-fix-buffer-advice)) +#+end_src + ** Completion *** Ivy, counsel, swiper Minibuffer completion tools for Emacs. @@ -1194,6 +1214,7 @@ Setting up quick access to various completions. "f" 'project-find-file "c" 'counsel-yank-pop "a" 'counsel-rg + "d" 'deadgrep "A" 'counsel-ag) (general-define-key