diff --git a/modules/completion/selectrum/TODO.org b/modules/completion/selectrum/TODO.org index ab33a675f..268b54066 100644 --- a/modules/completion/selectrum/TODO.org +++ b/modules/completion/selectrum/TODO.org @@ -32,6 +32,7 @@ https://github.com/oantolin/orderless/issues/41 https://github.com/minad/marginalia/issues/59 ** TODO =SPC s B= ** TODO =C-C C-e= wgrep fun +check if we can add this to ~consult-line~ too ** TODO bibtex-actions improvements? currently =SPC n b= is bound to a function, but =bibtex-actions= doesn't have a main dispatch function like =ivy-bibtex=, rather it has a bunch of different diff --git a/modules/completion/selectrum/autoload/selectrum.el b/modules/completion/selectrum/autoload/selectrum.el index 10e04ada0..071538145 100644 --- a/modules/completion/selectrum/autoload/selectrum.el +++ b/modules/completion/selectrum/autoload/selectrum.el @@ -74,3 +74,27 @@ If ARG (universal argument), include all files, even hidden or compressed ones." (defun +selectrum/search-symbol-at-point () (interactive) (consult-line (thing-at-point 'symbol))) + +;;;###autoload +(defun +selectrum/embark-wgrep () + "Invoke a wgrep buffer on the current selectrum results, if supported." + (interactive) + (require 'wgrep) + (pcase-let ((`(,type . ,candidates) + (run-hook-with-args-until-success 'embark-candidate-collectors))) + (if (null candidates) + (user-error "No candidates for export") + (if (eq type 'consult-grep) + (embark--quit-and-run + (lambda () + (let ((buf (generate-new-buffer "*Embark Export Wgrep*"))) + (with-current-buffer buf + (insert (propertize "Exported grep results:\n\n" 'wgrep-header t)) + (dolist (line candidates) (insert line "\n")) + (goto-char (point-min)) + (grep-mode) + (setq-local wgrep-header/footer-parser #'ignore) + (wgrep-setup)) + (pop-to-buffer buf) + (wgrep-change-to-wgrep-mode)))) + (user-error "embark category %S doesn't support wgrep" type))))) diff --git a/modules/completion/selectrum/config.el b/modules/completion/selectrum/config.el index e26d5e43b..d3869afe0 100644 --- a/modules/completion/selectrum/config.el +++ b/modules/completion/selectrum/config.el @@ -31,6 +31,7 @@ (map! :map selectrum-minibuffer-map "C-o" #'embark-act "C-c C-o" #'embark-export + "C-c C-e" #'+selectrum/embark-wgrep [backspace] #'+selectrum/backward-updir)) (use-package! selectrum-prescient @@ -123,7 +124,8 @@ :desc "Open target with sudo" "s" #'sudo-edit :desc "Open target with vlf" "l" #'vlf :map embark-file-map - :desc "Cycle marginalia views" "A" #'marginalia-cycle)) + :desc "Cycle marginalia views" "A" #'marginalia-cycle) + (set-popup-rule! "^\\*Embark Export" :size 0.35 :ttl 0 :quit nil)) (use-package! marginalia :hook (doom-first-input . marginalia-mode) @@ -134,6 +136,7 @@ (use-package! embark-consult :after (embark consult) + :demand t :hook (embark-collect-mode . embark-consult-preview-minor-mode))