selectrum: simplify +selectrum/embark-wgrep

now that oantolin/embark#226 has been resolved.
This commit is contained in:
Itai Y. Efrat 2021-05-20 22:20:20 +03:00
parent 436794aa87
commit 85be33556b
2 changed files with 5 additions and 18 deletions

View file

@ -81,19 +81,7 @@ If ARG (universal argument), include all files, even hidden or compressed ones."
(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)))))
(if (not (eq type 'consult-grep))
(user-error "embark category %S doesn't support wgrep" type)
(let ((embark-after-export-hook #'wgrep-change-to-wgrep-mode))
(embark-export)))))