Bind 'SPC h d l' for text-searching load-path

Co-authored-by: Rudi Grinberg <139003+rgrinberg@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2019-10-23 00:27:40 -04:00
parent 820264166c
commit 0df480bf85
No known key found for this signature in database
GPG Key ID: 5F6C0EA160557395
2 changed files with 29 additions and 0 deletions

View File

@ -570,3 +570,31 @@ config blocks in your private config."
"Open PACKAGE's repo or homepage in your browser."
(interactive (list (doom--package-list)))
(browse-url (doom--package-url package)))
;;;###autoload
(defun doom/help-search-load-path (query)
"Perform a text search on your `load-path'.
Uses the symbol at point or the current selection, if available."
(interactive
(let ((query
;; TODO Generalize this later; into something the lookup module and
;; project search commands could as well.
(if (use-region-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(or (symbol-name (symbol-at-point)) ""))))
(list (read-string
(format "Search load-path (default: %s): " query)
nil 'git-grep query))))
;; REVIEW Replace with deadgrep or ivy/helm interface when we drop ag/git-grep
;; support later
(grep-find
(mapconcat
#'shell-quote-argument
(cond ((executable-find "rg")
`("rg" "--search-zip" "--no-heading" "--color=never"
,query ,@(cl-remove-if-not #'file-directory-p load-path)))
((executable-find "ag")
`("ag" "--search-zip" "--nogroup" "--nocolor"
,query ,@(cl-remove-if-not #'file-directory-p load-path)))
((user-error "This command requires ripgrep or the_silver_searcher to be installed on your system")))
" ")))

View File

@ -313,6 +313,7 @@
"dd" #'doom/toggle-debug-mode
"df" #'doom/help-faq
"dh" #'doom/help
"dl" #'doom/help-search-load-path
"dm" #'doom/help-modules
"dn" #'doom/help-news
"dN" #'doom/help-news-search