cp-grep: no longer rely on counsel--git-dir

This variable was remove from counsel. Use default-directory instead
as done there.
This commit is contained in:
Eric Danan 2018-01-03 22:29:59 +01:00
parent d68af72c9e
commit 0a63f2210d

View file

@ -486,7 +486,7 @@ construct the command.")
"Grep for STRING in the current project." "Grep for STRING in the current project."
(if (< (length string) 3) (if (< (length string) 3)
(counsel-more-chars 3) (counsel-more-chars 3)
(let ((default-directory counsel--git-dir) (let ((default-directory (ivy-state-directory ivy-last))
(regex (counsel-unquote-regex-parens (regex (counsel-unquote-regex-parens
(setq ivy--old-re (setq ivy--old-re
(ivy--regex string))))) (ivy--regex string)))))
@ -507,7 +507,7 @@ construct the command.")
;; prepend "./" to the candidates since grep already does so. ;; prepend "./" to the candidates since grep already does so.
(unless (eq major-mode 'ivy-occur-grep-mode) (unless (eq major-mode 'ivy-occur-grep-mode)
(ivy-occur-grep-mode) (ivy-occur-grep-mode)
(setq default-directory counsel--git-dir)) (setq default-directory (ivy-state-directory ivy-last)))
(setq ivy-text (setq ivy-text
(and (string-match "\"\\(.*\\)\"" (buffer-name)) (and (string-match "\"\\(.*\\)\"" (buffer-name))
(match-string 1 (buffer-name)))) (match-string 1 (buffer-name))))
@ -560,11 +560,11 @@ called with a prefix argument."
(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)))
(default-directory (projectile-project-root)))
(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))
(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