Bind 'SPC h d S' to text search; expand ivy/helm file-search API
This commit is contained in:
parent
e8aa293bc0
commit
b144a3862a
4 changed files with 38 additions and 14 deletions
|
@ -196,7 +196,7 @@ selection of all minor-modes, active or not."
|
||||||
(find-file (expand-file-name "index.org" doom-docs-dir)))
|
(find-file (expand-file-name "index.org" doom-docs-dir)))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/help-search (&optional initial-input)
|
(defun doom/help-search-headings (&optional initial-input)
|
||||||
"Search Doom's documentation and jump to a headline."
|
"Search Doom's documentation and jump to a headline."
|
||||||
(interactive)
|
(interactive)
|
||||||
(doom-completing-read-org-headings
|
(doom-completing-read-org-headings
|
||||||
|
@ -212,6 +212,25 @@ selection of all minor-modes, active or not."
|
||||||
x)
|
x)
|
||||||
(doom--help-modules-list))))
|
(doom--help-modules-list))))
|
||||||
|
|
||||||
|
;;;###autoload
|
||||||
|
(defun doom/help-search (&optional initial-input)
|
||||||
|
"Preform a text search on all of Doom's documentation."
|
||||||
|
(interactive)
|
||||||
|
(funcall (cond ((featurep! :completion ivy)
|
||||||
|
#'+ivy-file-search)
|
||||||
|
((featurep! :completion helm)
|
||||||
|
#'+helm-file-search)
|
||||||
|
((rgrep
|
||||||
|
(read-regexp
|
||||||
|
"Search for" (or initial-input 'grep-tag-default)
|
||||||
|
'grep-regexp-history)
|
||||||
|
"*.org" doom-emacs-dir)
|
||||||
|
#'ignore))
|
||||||
|
:query initial-input
|
||||||
|
:args '("-g" "*.org")
|
||||||
|
:in doom-emacs-dir
|
||||||
|
:prompt "Search documentation for: "))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun doom/help-news-search (&optional initial-input)
|
(defun doom/help-news-search (&optional initial-input)
|
||||||
"Search headlines in Doom's newsletters."
|
"Search headlines in Doom's newsletters."
|
||||||
|
|
|
@ -38,7 +38,7 @@ workspace."
|
||||||
;;; Project search
|
;;; Project search
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(cl-defun +helm-file-search (&key query in all-files (recursive t))
|
(cl-defun +helm-file-search (&key query in all-files (recursive t) _prompt args)
|
||||||
"Conduct a file search using ripgrep.
|
"Conduct a file search using ripgrep.
|
||||||
|
|
||||||
:query STRING
|
:query STRING
|
||||||
|
@ -55,8 +55,9 @@ workspace."
|
||||||
(let ((this-command 'helm-rg)
|
(let ((this-command 'helm-rg)
|
||||||
(helm-rg-default-directory (or in (doom-project-root) default-directory))
|
(helm-rg-default-directory (or in (doom-project-root) default-directory))
|
||||||
(helm-rg-default-extra-args
|
(helm-rg-default-extra-args
|
||||||
(delq nil (list (when all-files "-z -uu")
|
(delq nil (append (list (when all-files "-z -uu")
|
||||||
(unless recursive "--maxdepth 1")))))
|
(unless recursive "--maxdepth 1"))
|
||||||
|
args))))
|
||||||
(helm-rg (or query
|
(helm-rg (or query
|
||||||
(when (use-region-p)
|
(when (use-region-p)
|
||||||
(let ((beg (or (bound-and-true-p evil-visual-beginning) (region-beginning)))
|
(let ((beg (or (bound-and-true-p evil-visual-beginning) (region-beginning)))
|
||||||
|
|
|
@ -242,7 +242,7 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
|
||||||
(#'counsel-file-jump)))))
|
(#'counsel-file-jump)))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(cl-defun +ivy-file-search (&key query in all-files (recursive t))
|
(cl-defun +ivy-file-search (&key query in all-files (recursive t) prompt args)
|
||||||
"Conduct a file search using ripgrep.
|
"Conduct a file search using ripgrep.
|
||||||
|
|
||||||
:query STRING
|
:query STRING
|
||||||
|
@ -260,7 +260,9 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
|
||||||
(project-root (or (doom-project-root) default-directory))
|
(project-root (or (doom-project-root) default-directory))
|
||||||
(directory (or in project-root))
|
(directory (or in project-root))
|
||||||
(args (concat (if all-files " -uu")
|
(args (concat (if all-files " -uu")
|
||||||
(unless recursive " --maxdepth 1"))))
|
(unless recursive " --maxdepth 1")
|
||||||
|
" "
|
||||||
|
(mapconcat #'shell-quote-argument args " "))))
|
||||||
(counsel-rg
|
(counsel-rg
|
||||||
(or (if query query)
|
(or (if query query)
|
||||||
(when (use-region-p)
|
(when (use-region-p)
|
||||||
|
@ -278,13 +280,14 @@ The point of this is to avoid Emacs locking up indexing massive file trees."
|
||||||
((concat "\\\\" substr))))
|
((concat "\\\\" substr))))
|
||||||
(rxt-quote-pcre query)))))))
|
(rxt-quote-pcre query)))))))
|
||||||
directory args
|
directory args
|
||||||
|
(or prompt
|
||||||
(format "rg%s [%s]: "
|
(format "rg%s [%s]: "
|
||||||
args
|
args
|
||||||
(cond ((equal directory default-directory)
|
(cond ((equal directory default-directory)
|
||||||
"./")
|
"./")
|
||||||
((equal directory project-root)
|
((equal directory project-root)
|
||||||
(projectile-project-name))
|
(projectile-project-name))
|
||||||
((file-relative-name directory project-root)))))))
|
((file-relative-name directory project-root))))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +ivy/project-search (&optional arg initial-query directory)
|
(defun +ivy/project-search (&optional arg initial-query directory)
|
||||||
|
|
|
@ -328,7 +328,8 @@
|
||||||
"dP" #'doom/help-package-homepage
|
"dP" #'doom/help-package-homepage
|
||||||
"dc" #'doom/goto-config-file
|
"dc" #'doom/goto-config-file
|
||||||
"dC" #'doom/help-package-config
|
"dC" #'doom/help-package-config
|
||||||
"ds" #'doom/help-search
|
"ds" #'doom/help-search-headings
|
||||||
|
"dS" #'doom/help-search
|
||||||
"dx" #'doom/sandbox
|
"dx" #'doom/sandbox
|
||||||
"dt" #'doom/toggle-profiler
|
"dt" #'doom/toggle-profiler
|
||||||
"dv" #'doom/version
|
"dv" #'doom/version
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue