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:
parent
0681753929
commit
ae75a9df9c
1 changed files with 13 additions and 0 deletions
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue