diff options
| author | Grégoire Duchêne <gduchene@awhk.org> | 2022-01-15 13:48:37 +0000 |
|---|---|---|
| committer | Grégoire Duchêne <gduchene@awhk.org> | 2022-01-15 13:48:37 +0000 |
| commit | 240973f98e87431a5678188f653224013b9501a8 (patch) | |
| tree | c1113e97d89b587e4deb581c289dcdd6f6303f51 /emacs/functions.el | |
| parent | 890c31f329c9f17641a6f4068aa3ae7116b60db6 (diff) | |
emacs: Add my/swiper and bind it to C-c s
If the region is active, my/swiper will call swiper with the contents of
the region as initial input. Also, When invoked with a prefix argument,
swiper-all is called instead.
Diffstat (limited to 'emacs/functions.el')
| -rw-r--r-- | emacs/functions.el | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/emacs/functions.el b/emacs/functions.el index fc8431f..b322af6 100644 --- a/emacs/functions.el +++ b/emacs/functions.el @@ -19,6 +19,17 @@ is active." (isearch-yank-string (buffer-substring-no-properties (region-beginning) (region-end))))) +(defun my/swiper (&optional swiper-all) + "Call ‘swiper’ (‘swiper-all’ when prefixed) with the contents +of the region if it is active." + (interactive "P") + (if (use-region-p) + (let ((initial-input (buffer-substring-no-properties + (region-beginning) (region-end)))) + (deactivate-mark) + (if swiper-all (swiper-all initial-input) (swiper initial-input))) + (if swiper-all (swiper-all) (swiper)))) + ;; Theme Functions |
