[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 871f78c 168/272: Add optional exit-code table to counsel--
From: |
Oleh Krehel |
Subject: |
[elpa] master 871f78c 168/272: Add optional exit-code table to counsel--async-cmd |
Date: |
Mon, 25 Apr 2016 10:13:23 +0000 |
branch: master
commit 871f78cc9fea6c2c86e0d68a89df0a9dc9aad8b5
Author: justbur <address@hidden>
Commit: Oleh Krehel <address@hidden>
Add optional exit-code table to counsel--async-cmd
This argument can be used to associate exit codes with the underlying
reason. Used in counsel-ag-function to signal that an exit code of 1
means that no matches were found.
Fixes #421
---
counsel.el | 26 ++++++++++++++++++++++++--
1 file changed, 24 insertions(+), 2 deletions(-)
diff --git a/counsel.el b/counsel.el
index 2c6c54c..2ea12d6 100644
--- a/counsel.el
+++ b/counsel.el
@@ -66,6 +66,18 @@
"Store the time when a new process was started.
Or the time of the last minibuffer update.")
+(defvar counsel--async-exit-code-plist nil
+ "Associates exit codes with reasons.")
+
+(defun counsel-set-async-exit-code (cmd number str)
+ "For CMD, associate NUMBER exit code with STR."
+ (let ((plist (plist-get counsel--async-exit-code-plist cmd)))
+ (setq counsel--async-exit-code-plist
+ (plist-put
+ counsel--async-exit-code-plist
+ cmd
+ (plist-put plist number str)))))
+
(defvar counsel-async-split-string-re "\n"
"Store the regexp for splitting shell command output.")
@@ -111,8 +123,14 @@ Or the time of the last minibuffer update.")
(ivy--insert-minibuffer "")
(ivy--exhibit)))
(if (string-match "exited abnormally with code \\([0-9]+\\)\n" event)
- (progn
- (setq ivy--all-candidates (list (format "error code %s"
(match-string 1 event))))
+ (let* ((exit-code-plist (plist-get counsel--async-exit-code-plist
+ (ivy-state-caller ivy-last)))
+ (exit-num (read (match-string 1 event)))
+ (exit-code (plist-get exit-code-plist exit-num)))
+ (setq ivy--all-candidates
+ (list
+ (or exit-code
+ (format "error code %d" exit-num))))
(setq ivy--old-cands ivy--all-candidates)
(ivy--exhibit)))))
@@ -1139,6 +1157,8 @@ string - the full shell command to run."
'(("x" counsel-locate-action-extern "xdg-open")
("d" counsel-locate-action-dired "dired")))
+(counsel-set-async-exit-code 'counsel-locate 1 "Nothing found")
+
(defvar counsel-locate-history nil
"History for `counsel-locate'.")
@@ -1205,6 +1225,8 @@ command. %S will be replaced by the regex string. The
default is
:type 'string
:group 'ivy)
+(counsel-set-async-exit-code 'counsel-ag 1 "No matches found")
+
(defun counsel-ag-function (string)
"Grep in the current directory for STRING."
(if (< (length string) 3)
- [elpa] master 2fb8d86 260/272: ivy.el (ivy-done): Allow ivy-dispatching-done to exit with no cands, (continued)
- [elpa] master 2fb8d86 260/272: ivy.el (ivy-done): Allow ivy-dispatching-done to exit with no cands, Oleh Krehel, 2016/04/25
- [elpa] master 1c68495 145/272: ivy.el (ivy-expand-file-if-directory): New defun, Oleh Krehel, 2016/04/25
- [elpa] master d4fc54b 110/272: ivy-test.el (counsel-unquote-regex-parens): Add test, Oleh Krehel, 2016/04/25
- [elpa] master 5f0d175 172/272: counsel.el (counsel-prompt-function-dir): Make portable, Oleh Krehel, 2016/04/25
- [elpa] master 5765208 185/272: counsel.el (counsel-pt-base-command): Add regex flag, Oleh Krehel, 2016/04/25
- [elpa] master 67ac850 211/272: counsel.el (counsel-M-x): Add help action, Oleh Krehel, 2016/04/25
- [elpa] master 189c093 207/272: counsel.el (counsel-ace-link): New command, Oleh Krehel, 2016/04/25
- [elpa] master 8c2f213 059/272: counsel.el (counsel-yank-pop): Truncate during display, Oleh Krehel, 2016/04/25
- [elpa] master 5c2c1df 166/272: counsel.el (counsel-git-grep-map): Bind "C-c C-m" to counsel-git-grep-switch-cmd, Oleh Krehel, 2016/04/25
- [elpa] master e6f92fd 191/272: ivy.el (ivy-occur-press): Add counsel-describe-function, Oleh Krehel, 2016/04/25
- [elpa] master 871f78c 168/272: Add optional exit-code table to counsel--async-cmd,
Oleh Krehel <=
- [elpa] master 668aaf3 155/272: counsel.el: add outline for `counsel-mode', Oleh Krehel, 2016/04/25
- [elpa] master 2a13932 252/272: counsel.el (counsel-grep-or-swiper): New command, Oleh Krehel, 2016/04/25
- [elpa] master 0b51e8e 231/272: ivy.el (ivy-minibuffer-map): Fix "DEL", Oleh Krehel, 2016/04/25
- [elpa] master cf78d42 212/272: counsel.el (counsel-find-file): Add :caller, Oleh Krehel, 2016/04/25
- [elpa] master a25e174 248/272: ivy.el (ivy--format-minibuffer-line): Add ignore-errors, Oleh Krehel, 2016/04/25
- [elpa] master ebd3fb9 254/272: Fix read-file-name with specified dir, Oleh Krehel, 2016/04/25
- [elpa] master 7dc86b3 084/272: Add a lot of sections to the documentation, Oleh Krehel, 2016/04/25
- [elpa] master d2a89ea 261/272: doc/ivy.org: Add a note on :predicate, Oleh Krehel, 2016/04/25
- [elpa] master 63a77ba 162/272: swiper.el (swiper-occur): Fix for non-file buffers, Oleh Krehel, 2016/04/25
- [elpa] master d899181 199/272: README.md: Add a section on Contributing, Oleh Krehel, 2016/04/25