From ae75a9df9cc492fcdc80e11d68f7567f758f2b6a Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 10 Jan 2020 20:30:52 +0000 Subject: Configure deadgrep Configuring deadgrep to do a number of things: 1. Set `deadgrep--context` to see more context "after" in the output. 2. Define `deadgrep/dwim` to use a region if one is present; otherwise just behave as `deadgrep`. Warning: This commit relies on a patch I made to deadgrep: supporting the `deadgrep--additional-flags`. --- configs/shared/.emacs.d/wpc/packages/wpc-misc.el | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'configs/shared/.emacs.d/wpc/packages/wpc-misc.el') diff --git a/configs/shared/.emacs.d/wpc/packages/wpc-misc.el b/configs/shared/.emacs.d/wpc/packages/wpc-misc.el index 2515633fd55b..18f1e76dd80c 100644 --- a/configs/shared/.emacs.d/wpc/packages/wpc-misc.el +++ b/configs/shared/.emacs.d/wpc/packages/wpc-misc.el @@ -148,6 +148,19 @@ :keymaps 'deadgrep-mode-map :states 'normal "o" #'deadgrep-visit-result-other-window) + (setq-default deadgrep--context '(0 . 3)) + (defun deadgrep/region () + "Run a ripgrep search on the active region." + (interactive) + (deadgrep (region/to-string))) + (defun deadgrep/dwim () + "If a region is active, use that as the search, otherwise don't." + (interactive) + (with-current-buffer (current-buffer) + (if (region-active-p) + (setq deadgrep--additional-flags '("--multiline")) + (deadgrep/region) + (call-interactively #'deadgrep)))) (advice-add 'deadgrep--format-command :filter-return -- cgit 1.4.1