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`.
This commit is contained in:
William Carroll 2020-01-10 20:30:52 +00:00
parent 0681753929
commit ae75a9df9c

View file

@ -148,6 +148,19 @@
:keymaps 'deadgrep-mode-map :keymaps 'deadgrep-mode-map
:states 'normal :states 'normal
"o" #'deadgrep-visit-result-other-window) "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 (advice-add
'deadgrep--format-command 'deadgrep--format-command
:filter-return :filter-return