Add +default/search-from-cwd & +default/search-project

This commit is contained in:
Henrik Lissner 2019-03-07 23:24:16 -05:00
parent 748b197676
commit f2b8280b2a
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 33 additions and 6 deletions

View file

@ -218,3 +218,34 @@ possible, or just one char if that's not possible."
((doom--backward-delete-whitespace-to-column)))))))
;; Otherwise, do simple deletion.
((delete-char (- n) killflag))))
;;;###autoload
(defun +default/search-from-cwd (&optional arg)
"Conduct a text search in files under the current folder.
If prefix ARG is set, prompt for a directory to search from."
(interactive "P")
(let ((default-directory
(if arg
(read-directory-name "Switch to project: " default-directory)
default-directory)))
(call-interactively
(cond ((featurep! :completion ivy) #'+ivy/project-search-from-cwd)
((featurep! :completion helm) #'+helm/project-search-from-cwd)
(#'projectile-grep)))))
;;;###autoload
(defun +default/search-project (&optional arg)
"Conduct a text search in files under the project root.
If prefix ARG is set, prompt for a project to search from."
(interactive "P")
(let ((default-directory
(if arg
(if-let* ((projects (projectile-relevant-known-projects)))
(completing-read "Switch to project: " projects
nil t nil nil (doom-project-root))
(user-error "There are no known projects"))
default-directory)))
(call-interactively
(cond ((featurep! :completion ivy) #'+ivy/project-search)
((featurep! :completion helm) #'+helm/project-search)
(#'rgrep)))))