diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2024-08-24 09:24:32 +0100 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2024-08-24 09:24:32 +0100 |
| commit | 8264d04f982968148fd1e66c02efce88d452c415 (patch) | |
| tree | 0867ccd3f17efdbac172a6e8d5e7b40313cf6764 | |
| parent | 248bf0b9fcd420f4297058fc49c9181cc767a50b (diff) | |
emacs: Pass region contents to ‘consult-ripgrep’
| -rw-r--r-- | emacs/functions.el | 10 | ||||
| -rw-r--r-- | emacs/init.el | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/emacs/functions.el b/emacs/functions.el index 9eb405b..b6e7f1f 100644 --- a/emacs/functions.el +++ b/emacs/functions.el @@ -11,6 +11,16 @@ ;; Search Helpers +(defun my/consult-ripgrep (&optional dir) + "Call ‘consult-ripgrep’ with the contents of the region as INITIAL +when possible." + (interactive) + (if (not (use-region-p)) + (consult-ripgrep dir) + (deactivate-mark) + (consult-ripgrep dir (buffer-substring-no-properties + (region-beginning) (region-end))))) + (defun my/isearch-region (&rest _args) "Pull the contents of the region into the search string if it is active." diff --git a/emacs/init.el b/emacs/init.el index f03c16c..9012a0d 100644 --- a/emacs/init.el +++ b/emacs/init.el @@ -95,7 +95,7 @@ (use-package consult :bind (("C-x b" . consult-buffer) - ("C-c s" . consult-ripgrep)) + ("C-c s" . my/consult-ripgrep)) :ensure t) (use-package orderless |
