Skip to content

Instantly share code, notes, and snippets.

@hidsh
Created January 2, 2023 03:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hidsh/61418c02ac714f2b2894f1ed24eba365 to your computer and use it in GitHub Desktop.
Save hidsh/61418c02ac714f2b2894f1ed24eba365 to your computer and use it in GitHub Desktop.
elisp: consult-ripgrep with symbol-at-point and directory to search
(defun my-consult-ripgrep (&optional parg dir initial)
"`consult-ripgrep` with symbol-at-point.
Besides, it can be Specified top directory to search using prefix-argument, e.g. C-u."
(interactive "p")
(setq initial (thing-at-point 'symbol))
(setq dir (pcase parg
(1 nil) ;; not given prefix-arg
(t (let ((insert-default-directory t))
(read-directory-name "Ripgrep Dir: ")))))
(consult-ripgrep dir initial)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment