[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e86cf2e 010/399: counsel.el (counsel-require-program): Cha
From: |
Oleh Krehel |
Subject: |
[elpa] master e86cf2e 010/399: counsel.el (counsel-require-program): Change arg meaning |
Date: |
Sat, 20 Jul 2019 14:56:38 -0400 (EDT) |
branch: master
commit e86cf2ecffa2061586952d78b7a95782f4957453
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel-require-program): Change arg meaning
Since previously the arg was obtained with (car (split-string cmd)),
just bake that into the function.
When cmd is a string that starts with a space, skip the check. Useful
if cmd begins with "cd".
Fixes #1911
---
counsel.el | 54 +++++++++++++++++++++++++++++-------------------------
1 file changed, 29 insertions(+), 25 deletions(-)
diff --git a/counsel.el b/counsel.el
index 7cde99c..d4ddf7d 100644
--- a/counsel.el
+++ b/counsel.el
@@ -99,12 +99,18 @@ complex regexes."
str)
str))
-(defun counsel-require-program (program)
- "Check system for PROGRAM, printing error if unfound."
- (or (and (stringp program)
- (not (string= program ""))
- (executable-find program))
- (user-error "Required program \"%s\" not found in your path" program)))
+(defun counsel-require-program (cmd)
+ "Check system for program used in CMD, printing error if unfound.
+CMD is either a string or a list of strings.
+To skip the `executable-find' check, start the string with a space."
+ (unless (and (stringp cmd) (string-match-p "^ " cmd))
+ (let ((program (if (listp cmd)
+ (car cmd)
+ (car (split-string cmd)))))
+ (or (and (stringp program)
+ (not (string= program ""))
+ (executable-find program))
+ (user-error "Required program \"%s\" not found in your path"
program)))))
(defun counsel-prompt-function-default ()
"Return prompt appended with a semicolon."
@@ -1167,7 +1173,7 @@ selected face."
"Find file in the current Git repository.
INITIAL-INPUT can be given as the initial minibuffer input."
(interactive)
- (counsel-require-program (car (split-string counsel-git-cmd)))
+ (counsel-require-program counsel-git-cmd)
(let* ((default-directory (expand-file-name (counsel-locate-git-root)))
(cands (split-string
(shell-command-to-string counsel-git-cmd)
@@ -1409,7 +1415,7 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
proj)
(setq proj (car proj-and-cmd))
(setq counsel-git-grep-cmd (cdr proj-and-cmd))
- (counsel-require-program (car (split-string counsel-git-grep-cmd)))
+ (counsel-require-program counsel-git-grep-cmd)
(let ((collection-function
(if proj
#'counsel-git-grep-proj-function
@@ -2335,7 +2341,7 @@ INITIAL-INPUT can be given as the initial minibuffer
input."
(let ((default-directory counsel--fzf-dir))
(setq ivy--old-re (ivy--regex-fuzzy str))
(counsel--async-command
- (list "fzf" "-f" str)))
+ (format counsel-fzf-cmd str)))
nil)
;;;###autoload
@@ -2351,20 +2357,18 @@ FZF-PROMPT, if non-nil, is passed as `ivy-read' prompt
argument."
(read-directory-name (concat
fzf-basename
" in directory: "))))))
-
- (let ((fzf-basename (car (split-string counsel-fzf-cmd))))
- (counsel-require-program fzf-basename)
- (setq counsel--fzf-dir
- (or initial-directory
- (funcall counsel-fzf-dir-function)))
- (ivy-read (or fzf-prompt (concat fzf-basename ": "))
- #'counsel-fzf-function
- :initial-input initial-input
- :re-builder #'ivy--regex-fuzzy
- :dynamic-collection t
- :action #'counsel-fzf-action
- :unwind #'counsel-delete-process
- :caller 'counsel-fzf)))
+ (counsel-require-program counsel-fzf-cmd)
+ (setq counsel--fzf-dir
+ (or initial-directory
+ (funcall counsel-fzf-dir-function)))
+ (ivy-read (or fzf-prompt "fzf: ")
+ #'counsel-fzf-function
+ :initial-input initial-input
+ :re-builder #'ivy--regex-fuzzy
+ :dynamic-collection t
+ :action #'counsel-fzf-action
+ :unwind #'counsel-delete-process
+ :caller 'counsel-fzf))
(defun counsel-fzf-action (x)
"Find file X in current fzf directory."
@@ -2588,7 +2592,7 @@ EXTRA-AG-ARGS string, if non-nil, is appended to
`counsel-ag-base-command'.
AG-PROMPT, if non-nil, is passed as `ivy-read' prompt argument."
(interactive)
(setq counsel-ag-command counsel-ag-base-command)
- (counsel-require-program (car (split-string counsel-ag-command)))
+ (counsel-require-program counsel-ag-command)
(when current-prefix-arg
(setq initial-directory
(or initial-directory
@@ -2788,7 +2792,7 @@ When non-nil, INITIAL-INPUT is the initial search
pattern."
(interactive)
(unless buffer-file-name
(user-error "Current buffer is not visiting a file"))
- (counsel-require-program (car (split-string counsel-grep-base-command)))
+ (counsel-require-program counsel-grep-base-command)
(setq counsel-grep-last-line nil)
(setq counsel-grep-command
(format counsel-grep-base-command
- [elpa] master 70ad031 004/399: doc/Changelog.org: Update path to CSS, (continued)
- [elpa] master 70ad031 004/399: doc/Changelog.org: Update path to CSS, Oleh Krehel, 2019/07/20
- [elpa] master 596461e 005/399: counsel.el (counsel-grep-use-swiper-p): New defcustom, Oleh Krehel, 2019/07/20
- [elpa] master 6017cc8 006/399: ivy.el (ivy-read): Keep only one action for one key, Oleh Krehel, 2019/07/20
- [elpa] master dc250bd 008/399: counsel.el (counsel-unicode-char): Don't sort every time, Oleh Krehel, 2019/07/20
- [elpa] master b000b0a 007/399: ivy.el (ivy--recompute-index): Speed up, Oleh Krehel, 2019/07/20
- [elpa] master c2eb4b5 009/399: ivy.el (ivy--kill-buffer-action): Integrate with ivy-switch-buffer-kill, Oleh Krehel, 2019/07/20
- [elpa] master f631d75 013/399: swiper.el (swiper-font-lock-exclude): Add xref--xref-buffer-mode, Oleh Krehel, 2019/07/20
- [elpa] master 3773c26 015/399: swiper.el (swiper--current-window-start): Add docstring, Oleh Krehel, 2019/07/20
- [elpa] master da85d1e 016/399: ivy.el: Require TRAMP earlier, Oleh Krehel, 2019/07/20
- [elpa] master 98b70a7 011/399: swiper.el (swiper--update-input-ivy): Don't recenter when non-graphical, Oleh Krehel, 2019/07/20
- [elpa] master e86cf2e 010/399: counsel.el (counsel-require-program): Change arg meaning,
Oleh Krehel <=
- [elpa] master 007d672 012/399: swiper.el (swiper--update-input-ivy): Use display-graphic-p, Oleh Krehel, 2019/07/20
- [elpa] master 686cf5a 014/399: swiper.el (swiper--action): Fix for emacs -nw, Oleh Krehel, 2019/07/20
- [elpa] master b1ac725 017/399: ivy.el (ivy-initial-inputs-alist): Now a defcustom., Oleh Krehel, 2019/07/20
- [elpa] master 43f169b 019/399: swiper.el (swiper-font-lock-ensure-p): Try checking for non prog-mode, Oleh Krehel, 2019/07/20
- [elpa] master 24c95b7 018/399: ivy.el (ivy-thing-at-point): Extend, Oleh Krehel, 2019/07/20
- [elpa] master 51446e5 021/399: swiper.el (swiper--avy-candidates): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 050b4a4 023/399: counsel.el (counsel-grep-history): Add, Oleh Krehel, 2019/07/20
- [elpa] master 88b3548 020/399: swiper.el (swiper--avy-goto): Extract, Oleh Krehel, 2019/07/20
- [elpa] master 28e88ab 025/399: Allow to mark/unmark candidates with "m", "u", "DEL", "t", Oleh Krehel, 2019/07/20
- [elpa] master 48c7087 028/399: ivy.el (ivy-reverse-i-search): Don't bind ivy-recursive-restore to nil, Oleh Krehel, 2019/07/20