prot-consult: remove needless rg/fd wrappers

Just use what consult.el provides: it works well.  Those wrappers did
not offer anything over the standard options.

Also autoload relevant commands in prot-embark-extras.el, in accordance
with what was done in recent commits, such as 0740aa2b.  Those calls it
had to require libraries were not necessary.
This commit is contained in:
Protesilaos Stavrou 2021-01-19 19:57:32 +02:00
parent 0740aa2b4b
commit 6f31e3d4fc
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA
4 changed files with 20 additions and 74 deletions

View file

@ -1255,6 +1255,8 @@ try.
("M-g M-g" . consult-goto-line)
("M-X" . consult-mode-command)
("M-K" . consult-keep-lines) ; M-S-k is similar to M-S-5 (M-%)
("M-s f" . consult-find)
("M-s g" . consult-grep)
("M-s m" . consult-mark)
:map consult-narrow-map
("?" . consult-narrow-help)))
@ -1278,9 +1280,7 @@ try.
:bind (("M-s i" . prot-consult-imenu)
("M-s s" . prot-consult-outline) ; M-s o is `occur'
("M-s y" . prot-consult-yank)
("M-s l" . prot-consult-line)
("M-s f" . prot-consult-fd)
("M-s g" . prot-consult-rg)))
("M-s l" . prot-consult-line)))
#+end_src
Here is =prot-consult.el= (part of [[https://gitlab.com/protesilaos/dotfiles][my dotfiles' repo]]):
@ -1688,9 +1688,7 @@ add them to the list of Embark's known keymaps.
:demand
:config
(prot-embark-extras-keymaps 1)
(prot-embark-extras-setup-packages 1)
:bind (:map embark-symbol-map
("g" . prot-consult-rg-ref)))
(prot-embark-extras-setup-packages 1))
#+end_src
This is =prot-embark-extras.el= (part of [[https://gitlab.com/protesilaos/dotfiles][my dotfiles' repo]]):
@ -2283,13 +2281,13 @@ given version-controlled (git) repo, see the section of this document on
("C-c d" . contrib/cd-bookmark)))
(use-package prot-dired
:disabled ; superseded by `prot-consult.el'
:disabled ; superseded by `consult.el'
:straight (:type built-in)
:bind (("M-s d" . prot-dired-fd-dirs)
("M-s z" . prot-dired-fd-files-and-dirs)))
;; NOTE 2021-01-04: deprecated first in favour of `prot-dired.el' and
;; eventually by `prot-consult.el'
;; eventually by `consult.el'
(use-package find-dired
:disabled
:after dired

View file

@ -2775,6 +2775,7 @@ by virtue of calling either of `modus-themes-load-operandi' and
`(consult-key ((,class :inherit modus-themes-bold :foreground ,magenta-alt-other)))
`(consult-lighter ((,class :inherit shadow)))
`(consult-line-number ((,class :foreground ,fg-special-warm)))
`(consult-line-number-prefix ((,class :foreground ,fg-unfocused)))
`(consult-off ((,class :inherit error)))
`(consult-on ((,class :inherit success)))
`(consult-preview-cursor ((,class :inherit modus-theme-intense-blue)))

View file

@ -57,19 +57,6 @@ changes to take effect."
:group 'prot-consult
:type 'list)
(defcustom prot-consult-fd-flags '("fd" "-i" "-H" "-a" "-c" "never")
"List of strings for invoking the fd executable."
:type 'list
:group 'prot-consult)
(defcustom prot-consult-rg-flags
'("rg" "--null" "--line-buffered" "--color=always"
"--hidden" "-g" "!.git" "--max-columns=500"
"--no-heading" "--line-number" "." "-e")
"List of strings for invoking the rg executable."
:type 'list
:group 'prot-consult)
;;;; Setup for some consult commands (TODO: needs review)
(defvar prot-consult-jump-recentre-hook nil
@ -125,49 +112,6 @@ Intended to be assigned to `consult-project-root-function'."
(locate-dominating-file "." ".git")
default-directory))
(defun prot-consult--fd-flags (list)
"Append LIST to `prot-consult-fd-flags'."
(if (listp list)
(append prot-consult-fd-flags list)
(error "'%s' is not a list" list)))
;;;###autoload
(defun prot-consult-fd ()
"Use `consult--find' to search with the FD executable.
The search is performed against the root of the current version
controlled project or, if none is available, from inside the
`default-directory'."
(interactive)
(let* ((cmd prot-consult-fd-flags)
(default-directory (prot-consult-project-root))
(prompt (format "FdFind in %s: " (propertize default-directory 'face 'bold))))
(consult--find prompt cmd nil)))
(defvar consult--ripgrep-command)
(declare-function consult--grep "consult")
;;;###autoload
(defun prot-consult-rg ()
"Ripgrep with `consult--grep' in `prot-consult-project-root'."
(interactive)
(let* ((cmd prot-consult-rg-flags)
(default-directory (prot-consult-project-root))
(prompt (format "RipGrep in %s" (propertize default-directory 'face 'bold))))
(consult--grep prompt cmd default-directory nil)))
;;;###autoload
(defun prot-consult-rg-ref (ref)
"Ripgrep REF with Consult in `prot-consult-project-root'."
(interactive
(list (read-regexp "Search regexp: ")))
(let* ((cmd prot-consult-rg-flags)
(default-directory (prot-consult-project-root))
(prompt (format "RipGrep %s in %s"
(propertize ref 'face 'success)
(propertize default-directory 'face 'bold))))
(consult--grep prompt cmd default-directory ref)))
;;;###autoload
(defun prot-consult-outline ()
"Run `consult-outline' through `prot-orderless-with-styles'."

View file

@ -29,23 +29,20 @@
;;; Code:
(when (featurep 'embark)
(require 'embark))
(require 'prot-consult)
(require 'prot-embark)
(require 'prot-recentf)
(defgroup prot-embark-extras ()
"Custom cross-package extensions for `embark'."
:group 'editing)
(autoload 'prot-consult-fd "prot-consult")
(autoload 'prot-consult-rg "prot-consult")
(autoload 'consult-find "consult")
(autoload 'consult-grep "consult")
(autoload 'consult-line "consult")
(autoload 'consult-imenu "consult")
(autoload 'consult-outline "consult")
(defvar prot-embark-extras-become-general-map
(let ((map (make-sparse-keymap)))
(define-key map (kbd "f") 'prot-consult-fd)
(define-key map (kbd "g") 'prot-consult-rg)
(define-key map (kbd "f") 'consult-find)
(define-key map (kbd "g") 'consult-grep)
map)
"General custom cross-package `embark-become' keymap.")
@ -59,6 +56,8 @@
(defvar embark-become-file+buffer-map)
(autoload 'prot-recentf-recent-files "prot-recentf")
(autoload 'project-switch-to-buffer "project")
(autoload 'project-find-file "project")
(defvar prot-embark-extras-become-file+buffer-map
(let ((map (make-sparse-keymap)))
@ -110,6 +109,10 @@ To be used as filter-return advice to `embark-keymap-prompter'."
To be passed as advice before `embark-act' and others."
(force-mode-line-update t))
(autoload 'embark-act "embark")
(autoload 'embark-act-noexit "embark")
(autoload 'embark-become "embark")
;; NOTE: This has a generic name because my plan is to add more packages
;; to it.
;;;###autoload