Refactor helm commands
This commit is contained in:
parent
7b2e80c711
commit
ce22e21853
1 changed files with 21 additions and 10 deletions
|
@ -162,9 +162,10 @@ order.
|
||||||
(string-join (delq nil (cdr command)) " ")
|
(string-join (delq nil (cdr command)) " ")
|
||||||
(abbreviate-file-name directory))
|
(abbreviate-file-name directory))
|
||||||
helm-source-do-ag)
|
helm-source-do-ag)
|
||||||
(cl-letf ((+helm-global-prompt prompt)
|
(helm-attrset '+helm-command command helm-source-do-ag)
|
||||||
((symbol-function 'helm-do-ag--helm)
|
(cl-letf (((symbol-function 'helm-do-ag--helm)
|
||||||
(lambda () (helm :sources '(helm-source-do-ag)
|
(lambda () (helm :sources '(helm-source-do-ag)
|
||||||
|
:prompt prompt
|
||||||
:buffer "*helm-ag*"
|
:buffer "*helm-ag*"
|
||||||
:keymap helm-do-ag-map
|
:keymap helm-do-ag-map
|
||||||
:input query
|
:input query
|
||||||
|
@ -177,7 +178,7 @@ order.
|
||||||
return (intern (format format tool))))
|
return (intern (format format tool))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +helm/project-search (&optional all-files-p)
|
(defun +helm/project-search (&optional arg)
|
||||||
"Performs a project search from the project root.
|
"Performs a project search from the project root.
|
||||||
|
|
||||||
Uses the first available search backend from `+helm-project-search-engines'. If
|
Uses the first available search backend from `+helm-project-search-engines'. If
|
||||||
|
@ -186,10 +187,10 @@ ones, in the search."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(funcall (or (+helm--get-command "+helm/%s")
|
(funcall (or (+helm--get-command "+helm/%s")
|
||||||
#'+helm/grep)
|
#'+helm/grep)
|
||||||
(or all-files-p current-prefix-arg)))
|
arg))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +helm/project-search-from-cwd (&optional all-files-p)
|
(defun +helm/project-search-from-cwd (&optional arg)
|
||||||
"Performs a project search recursively from the current directory.
|
"Performs a project search recursively from the current directory.
|
||||||
|
|
||||||
Uses the first available search backend from `+helm-project-search-engines'. If
|
Uses the first available search backend from `+helm-project-search-engines'. If
|
||||||
|
@ -198,7 +199,7 @@ ones."
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(funcall (or (+helm--get-command "+helm/%s-from-cwd")
|
(funcall (or (+helm--get-command "+helm/%s-from-cwd")
|
||||||
#'+helm/grep-from-cwd)
|
#'+helm/grep-from-cwd)
|
||||||
(or all-files-p current-prefix-arg)))
|
arg))
|
||||||
|
|
||||||
|
|
||||||
;; Relative to project root
|
;; Relative to project root
|
||||||
|
@ -213,21 +214,31 @@ ones."
|
||||||
|
|
||||||
(dolist (engine `(,@(cl-remove-duplicates +helm-project-search-engines :from-end t) grep))
|
(dolist (engine `(,@(cl-remove-duplicates +helm-project-search-engines :from-end t) grep))
|
||||||
(defalias (intern (format "+helm/%s" engine))
|
(defalias (intern (format "+helm/%s" engine))
|
||||||
(lambda (all-files-p &optional query directory)
|
(lambda (arg &optional query directory)
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(+helm-file-search engine :query query :in directory :all-files all-files-p))
|
(+helm-file-search engine
|
||||||
|
:query query
|
||||||
|
:in directory
|
||||||
|
:all-files (and (not (null arg))
|
||||||
|
(listp arg))))
|
||||||
(format "Perform a project file search using %s.
|
(format "Perform a project file search using %s.
|
||||||
|
|
||||||
QUERY is a regexp. If omitted, the current selection is used. If no selection is
|
QUERY is a regexp. If omitted, the current selection is used. If no selection is
|
||||||
active, the last known search is used.
|
active, the last known search is used.
|
||||||
|
|
||||||
|
ARG is the universal argument. If a number is passed through it, e.g. C-u 3, then
|
||||||
|
|
||||||
If ALL-FILES-P, search compressed and hidden files as well."
|
If ALL-FILES-P, search compressed and hidden files as well."
|
||||||
engine))
|
engine))
|
||||||
|
|
||||||
(defalias (intern (format "+helm/%s-from-cwd" engine))
|
(defalias (intern (format "+helm/%s-from-cwd" engine))
|
||||||
(lambda (all-files-p &optional query)
|
(lambda (arg &optional query)
|
||||||
(interactive "P")
|
(interactive "P")
|
||||||
(+helm-file-search engine :query query :in default-directory :all-files all-files-p))
|
(+helm-file-search engine
|
||||||
|
:query query
|
||||||
|
:in default-directory
|
||||||
|
:all-files (and (not (null arg))
|
||||||
|
(listp arg))))
|
||||||
(format "Perform a project file search from the current directory using %s.
|
(format "Perform a project file search from the current directory using %s.
|
||||||
|
|
||||||
QUERY is a regexp. If omitted, the current selection is used. If no selection is
|
QUERY is a regexp. If omitted, the current selection is used. If no selection is
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue