rm unnecessary calls to projectile-project-p
This commit is contained in:
parent
e200bce2ff
commit
499bc4cc23
1 changed files with 77 additions and 83 deletions
|
|
@ -609,51 +609,49 @@ additional options to be passed to grep, or an alternative git
|
||||||
grep command. It is read from the minibuffer if the function is
|
grep command. It is read from the minibuffer if the function is
|
||||||
called with a prefix argument."
|
called with a prefix argument."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (projectile-project-p)
|
(if (and (eq (projectile-project-vcs) 'git)
|
||||||
(if (and (eq (projectile-project-vcs) 'git)
|
projectile-use-git-grep)
|
||||||
projectile-use-git-grep)
|
(let ((counsel-prompt-function
|
||||||
(let ((counsel-prompt-function
|
(lambda ()
|
||||||
(lambda ()
|
(ivy-add-prompt-count
|
||||||
(ivy-add-prompt-count
|
(format "%s: " (projectile-prepend-project-name (ivy-state-prompt ivy-last)))))))
|
||||||
(format "%s: " (projectile-prepend-project-name (ivy-state-prompt ivy-last)))))))
|
(counsel-git-grep (or current-prefix-arg options-or-cmd)
|
||||||
(counsel-git-grep (or current-prefix-arg options-or-cmd)
|
counsel-projectile-grep-initial-input))
|
||||||
counsel-projectile-grep-initial-input))
|
(counsel-require-program (car (split-string counsel-projectile-grep-base-command)))
|
||||||
(counsel-require-program (car (split-string counsel-projectile-grep-base-command)))
|
(let* ((ignored-files (mapconcat (lambda (i)
|
||||||
(let* ((ignored-files (mapconcat (lambda (i)
|
(concat "--exclude="
|
||||||
(concat "--exclude="
|
(shell-quote-argument i)
|
||||||
(shell-quote-argument i)
|
" "))
|
||||||
" "))
|
(projectile-ignored-files-rel)
|
||||||
(projectile-ignored-files-rel)
|
""))
|
||||||
""))
|
(ignored-dirs (mapconcat (lambda (i)
|
||||||
(ignored-dirs (mapconcat (lambda (i)
|
(concat "--exclude-dir="
|
||||||
(concat "--exclude-dir="
|
(shell-quote-argument i)
|
||||||
(shell-quote-argument i)
|
" "))
|
||||||
" "))
|
(projectile-ignored-directories-rel)
|
||||||
(projectile-ignored-directories-rel)
|
""))
|
||||||
""))
|
(ignored (concat ignored-files ignored-dirs))
|
||||||
(ignored (concat ignored-files ignored-dirs))
|
(options
|
||||||
(options
|
(if current-prefix-arg
|
||||||
(if current-prefix-arg
|
(read-string (projectile-prepend-project-name "grep options: ")
|
||||||
(read-string (projectile-prepend-project-name "grep options: ")
|
ignored
|
||||||
ignored
|
'counsel-projectile-grep-options-history)
|
||||||
'counsel-projectile-grep-options-history)
|
(concat ignored options-or-cmd))))
|
||||||
(concat ignored options-or-cmd))))
|
(setq counsel-projectile-grep-command
|
||||||
(setq counsel-projectile-grep-command
|
(format counsel-projectile-grep-base-command options))
|
||||||
(format counsel-projectile-grep-base-command options))
|
(ivy-set-prompt 'counsel-projectile-grep counsel-prompt-function)
|
||||||
(ivy-set-prompt 'counsel-projectile-grep counsel-prompt-function)
|
(setq counsel--git-dir (projectile-project-root))
|
||||||
(setq counsel--git-dir (projectile-project-root))
|
(ivy-read (projectile-prepend-project-name "grep")
|
||||||
(ivy-read (projectile-prepend-project-name "grep")
|
#'counsel-projectile-grep-function
|
||||||
#'counsel-projectile-grep-function
|
:initial-input counsel-projectile-grep-initial-input
|
||||||
:initial-input counsel-projectile-grep-initial-input
|
:dynamic-collection t
|
||||||
:dynamic-collection t
|
:keymap counsel-ag-map
|
||||||
:keymap counsel-ag-map
|
:history 'counsel-git-grep-history
|
||||||
:history 'counsel-git-grep-history
|
:action #'counsel-git-grep-action
|
||||||
:action #'counsel-git-grep-action
|
:unwind (lambda ()
|
||||||
:unwind (lambda ()
|
(counsel-delete-process)
|
||||||
(counsel-delete-process)
|
(swiper--cleanup))
|
||||||
(swiper--cleanup))
|
:caller 'counsel-projectile-grep))))
|
||||||
:caller 'counsel-projectile-grep)))
|
|
||||||
(user-error "You're not in a project")))
|
|
||||||
|
|
||||||
(counsel-set-async-exit-code 'counsel-projectile-grep 1 "No matches found")
|
(counsel-set-async-exit-code 'counsel-projectile-grep 1 "No matches found")
|
||||||
(ivy-set-occur 'counsel-projectile-grep 'counsel-projectile-grep-occur)
|
(ivy-set-occur 'counsel-projectile-grep 'counsel-projectile-grep-occur)
|
||||||
|
|
@ -672,25 +670,23 @@ OPTIONS, if non-nil, is a string containing additional options to
|
||||||
be passed to ag. It is read from the minibuffer if the function
|
be passed to ag. It is read from the minibuffer if the function
|
||||||
is called with a prefix argument."
|
is called with a prefix argument."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (projectile-project-p)
|
(let* ((ignored (mapconcat (lambda (i)
|
||||||
(let* ((ignored (mapconcat (lambda (i)
|
(concat "--ignore "
|
||||||
(concat "--ignore "
|
(shell-quote-argument i)
|
||||||
(shell-quote-argument i)
|
" "))
|
||||||
" "))
|
(append (projectile-ignored-files-rel)
|
||||||
(append (projectile-ignored-files-rel)
|
(projectile-ignored-directories-rel))
|
||||||
(projectile-ignored-directories-rel))
|
""))
|
||||||
""))
|
(options
|
||||||
(options
|
(if current-prefix-arg
|
||||||
(if current-prefix-arg
|
(read-string (projectile-prepend-project-name "ag options: ")
|
||||||
(read-string (projectile-prepend-project-name "ag options: ")
|
ignored
|
||||||
ignored
|
'counsel-projectile-ag-options-history)
|
||||||
'counsel-projectile-ag-options-history)
|
(concat ignored options))))
|
||||||
(concat ignored options))))
|
(counsel-ag (eval counsel-projectile-ag-initial-input)
|
||||||
(counsel-ag (eval counsel-projectile-ag-initial-input)
|
(projectile-project-root)
|
||||||
(projectile-project-root)
|
options
|
||||||
options
|
(projectile-prepend-project-name "ag"))))
|
||||||
(projectile-prepend-project-name "ag")))
|
|
||||||
(user-error "You're not in a project")))
|
|
||||||
|
|
||||||
;;; counsel-projectile-rg
|
;;; counsel-projectile-rg
|
||||||
|
|
||||||
|
|
@ -705,25 +701,23 @@ OPTIONS, if non-nil, is a string containing additional options to
|
||||||
be passed to rg. It is read from the minibuffer if the function
|
be passed to rg. It is read from the minibuffer if the function
|
||||||
is called with a prefix argument."
|
is called with a prefix argument."
|
||||||
(interactive)
|
(interactive)
|
||||||
(if (projectile-project-p)
|
(let* ((ignored (mapconcat (lambda (i)
|
||||||
(let* ((ignored (mapconcat (lambda (i)
|
(concat "--glob "
|
||||||
(concat "--glob "
|
(shell-quote-argument (concat "!" i))
|
||||||
(shell-quote-argument (concat "!" i))
|
" "))
|
||||||
" "))
|
(append (projectile-ignored-files-rel)
|
||||||
(append (projectile-ignored-files-rel)
|
(projectile-ignored-directories-rel))
|
||||||
(projectile-ignored-directories-rel))
|
""))
|
||||||
""))
|
(options
|
||||||
(options
|
(if current-prefix-arg
|
||||||
(if current-prefix-arg
|
(read-string (projectile-prepend-project-name "rg options: ")
|
||||||
(read-string (projectile-prepend-project-name "rg options: ")
|
ignored
|
||||||
ignored
|
'counsel-projectile-rg-options-history)
|
||||||
'counsel-projectile-rg-options-history)
|
(concat ignored options))))
|
||||||
(concat ignored options))))
|
(counsel-rg (eval counsel-projectile-rg-initial-input)
|
||||||
(counsel-rg (eval counsel-projectile-rg-initial-input)
|
(projectile-project-root)
|
||||||
(projectile-project-root)
|
options
|
||||||
options
|
(projectile-prepend-project-name "rg"))))
|
||||||
(projectile-prepend-project-name "rg")))
|
|
||||||
(user-error "You're not in a project")))
|
|
||||||
|
|
||||||
;;; counsel-projectile-org-capture
|
;;; counsel-projectile-org-capture
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue