[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 17d9c70 036/184: counsel.el (counsel--find-return-list): R
From: |
Oleh Krehel |
Subject: |
[elpa] master 17d9c70 036/184: counsel.el (counsel--find-return-list): Re-use counsel--call |
Date: |
Wed, 16 Oct 2019 13:14:44 -0400 (EDT) |
branch: master
commit 17d9c7056a244b6f725ee885c04ae38e8ae83613
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel--find-return-list): Re-use counsel--call
* counsel.el (counsel--command): Now forwards to `counsel--call'.
(counsel--call): Remove obsolete alias. Introduce as a generalization of
`counsel--command'
Re #2120
---
counsel.el | 44 +++++++++++++++++++++++++-------------------
1 file changed, 25 insertions(+), 19 deletions(-)
diff --git a/counsel.el b/counsel.el
index 2c8514b..748eb63 100644
--- a/counsel.el
+++ b/counsel.el
@@ -1416,13 +1416,12 @@ files in a project.")
(setq cmd counsel-git-grep-cmd-default)))
(cons proj cmd)))
-(define-obsolete-function-alias 'counsel--call 'counsel--command "0.11.0")
-
-(defun counsel--command (&rest command)
+(defun counsel--call (command &optional result-fn)
"Synchronously call COMMAND and return its output as a string.
COMMAND comprises the program name followed by its arguments, as
in `make-process'. Signal `file-error' and emit a warning if
-COMMAND fails. Obey file handlers based on `default-directory'."
+COMMAND fails. Obey file handlers based on `default-directory'.
+On success, RESULT-FN is called in output buffer with no arguments."
(let ((stderr (make-temp-file "counsel-call-stderr-"))
status)
(unwind-protect
@@ -1430,12 +1429,14 @@ COMMAND fails. Obey file handlers based on
`default-directory'."
(setq status (apply #'process-file (car command) nil
(list t stderr) nil (cdr command)))
(if (eq status 0)
- ;; Return all output except trailing newline.
- (buffer-substring (point-min)
- (- (point)
- (if (eq (bobp) (bolp))
- 0
- 1)))
+ (if result-fn
+ (funcall result-fn)
+ ;; Return all output except trailing newline.
+ (buffer-substring (point-min)
+ (- (point)
+ (if (eq (bobp) (bolp))
+ 0
+ 1))))
;; Convert process status into error list.
(setq status (list 'file-error
(mapconcat #'identity `(,@command "failed") "
")
@@ -1453,6 +1454,10 @@ COMMAND fails. Obey file handlers based on
`default-directory'."
(signal (car status) (cdr status))))
(delete-file stderr))))
+(defun counsel--command (&rest command)
+ "Forward COMMAND to `counsel--call'."
+ (counsel--call command))
+
;;;###autoload
(defun counsel-git-grep (&optional cmd initial-input)
"Grep for a string in the current Git repository.
@@ -2552,15 +2557,16 @@ FZF-PROMPT, if non-nil, is passed as `ivy-read' prompt
argument."
(defun counsel--find-return-list (args)
(unless (listp args)
(user-error "`counsel-file-jump-args' is a list now, please customize
accordingly."))
- (with-temp-buffer
- (apply #'process-file find-program nil (current-buffer) nil args)
- (goto-char (point-min))
- (let (files)
- (while (< (point) (point-max))
- (push (buffer-substring
- (+ 2 (line-beginning-position)) (line-end-position)) files)
- (forward-line 1))
- (nreverse files))))
+ (counsel--call
+ (cons find-program args)
+ (lambda ()
+ (goto-char (point-min))
+ (let (files)
+ (while (< (point) (point-max))
+ (push (buffer-substring
+ (+ 2 (line-beginning-position)) (line-end-position)) files)
+ (forward-line 1))
+ (nreverse files)))))
(defcustom counsel-file-jump-args (split-string ". -name .git -prune -o -type
f -print")
"Arguments for the `find-command' when using `counsel-file-jump'."
- [elpa] master c4e0b0b 032/184: ivy-test.el (ivy-read-file-name-make-directory): Add, (continued)
- [elpa] master c4e0b0b 032/184: ivy-test.el (ivy-read-file-name-make-directory): Add, Oleh Krehel, 2019/10/16
- [elpa] master fdd2178 042/184: ivy.el (ivy--magic-tilde-directory): Use "~~" to move to local home, Oleh Krehel, 2019/10/16
- [elpa] master a9196a2 035/184: counsel.el (counsel-file-jump-args): Is now a list, Oleh Krehel, 2019/10/16
- [elpa] master e58231e 033/184: ivy.el (ivy-immediate-done): Fix for when "C-j" changed cwd, Oleh Krehel, 2019/10/16
- [elpa] master 0132ced 044/184: counsel.el: Run ispell-comments-and-strings, Oleh Krehel, 2019/10/16
- [elpa] master c4842ec 043/184: Fix typo: 'beggining', Oleh Krehel, 2019/10/16
- [elpa] master 28e9416 052/184: ivy.el (ivy--input): Fix for ediff, Oleh Krehel, 2019/10/16
- [elpa] master dd3e1c9 038/184: swiper.el (swiper--maybe-recenter): Refactor, Oleh Krehel, 2019/10/16
- [elpa] master 5ff5139 051/184: ivy.el (ivy-read-action-function): Allow to read actions using Ivy, Oleh Krehel, 2019/10/16
- [elpa] master e4e0ec4 049/184: counsel.el (counsel--file-name-filter): Return "cat" on empty input, Oleh Krehel, 2019/10/16
- [elpa] master 17d9c70 036/184: counsel.el (counsel--find-return-list): Re-use counsel--call,
Oleh Krehel <=
- [elpa] master 44c4bab 057/184: Restore use-ignore setting on ivy-resume, Oleh Krehel, 2019/10/16
- [elpa] master d3e4514 063/184: Remove obsolete aliases older than one year, Oleh Krehel, 2019/10/16
- [elpa] master 0be5b58 067/184: ivy.el (ivy-partial): Don't rely on subr-x, Oleh Krehel, 2019/10/16
- [elpa] master a986e4e 071/184: ivy.el (ivy--yank-handle-case-fold): Add, Oleh Krehel, 2019/10/16
- [elpa] master e41cbec 073/184: ivy.el (ivy-immediate-done): Fix parent dirs for read-directory-name, Oleh Krehel, 2019/10/16
- [elpa] master 3256447 076/184: ivy.el (ivy--partial-cd-for-single-directory): Extract, Oleh Krehel, 2019/10/16
- [elpa] master 03b3f82 075/184: ivy.el (ivy-partial): Use ivy--filter in place of all-completions, Oleh Krehel, 2019/10/16
- [elpa] master daf4683 081/184: ivy.el (ivy--directory-done): Inhibit distracting TRAMP message for /sudo::, Oleh Krehel, 2019/10/16
- [elpa] master 9e03f36 095/184: ivy-test.el: Turn two tests back on, Oleh Krehel, 2019/10/16
- [elpa] master 4b7b075 093/184: ivy-test.el (ivy-test-inhibit-message): Add, Oleh Krehel, 2019/10/16