about summary refs log tree commit diff
path: root/configs/shared/.emacs.d/wpc/packages/wpc-misc.el
diff options
context:
space:
mode:
Diffstat (limited to 'configs/shared/.emacs.d/wpc/packages/wpc-misc.el')
-rw-r--r--configs/shared/.emacs.d/wpc/packages/wpc-misc.el13
1 files changed, 13 insertions, 0 deletions
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