[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 50f3092 169/272: counsel.el (counsel--async-sentinel): Sta
From: |
Oleh Krehel |
Subject: |
[elpa] master 50f3092 169/272: counsel.el (counsel--async-sentinel): Start refactor |
Date: |
Mon, 25 Apr 2016 10:13:23 +0000 |
branch: master
commit 50f309204d51d7e8bf3a4910854ccdf23cece49f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
counsel.el (counsel--async-sentinel): Start refactor
This function should only care about producing a list of strings from
the process buffer.
A new function should take this list and take care of everything else.
---
counsel.el | 73 +++++++++++++++++++++++++++++++-----------------------------
1 file changed, 38 insertions(+), 35 deletions(-)
diff --git a/counsel.el b/counsel.el
index 2ea12d6..53da889 100644
--- a/counsel.el
+++ b/counsel.el
@@ -98,41 +98,44 @@ Or the time of the last minibuffer update.")
(set-process-filter proc (or process-filter #'counsel--async-filter))))
(defun counsel--async-sentinel (process event)
- (if (string= event "finished\n")
- (progn
- (with-current-buffer (process-buffer process)
- (ivy--set-candidates
- (ivy--sort-maybe
- (split-string
- (buffer-string)
- counsel-async-split-string-re
- t)))
- (if (null ivy--old-cands)
- (setq ivy--index
- (or (ivy--preselect-index
- (ivy-state-preselect ivy-last)
- ivy--all-candidates)
- 0))
- (let ((re (funcall ivy--regex-function ivy-text)))
- (unless (stringp re)
- (setq re (caar re)))
- (ivy--recompute-index
- ivy-text re ivy--all-candidates)))
- (setq ivy--old-cands ivy--all-candidates))
- (if (null ivy--all-candidates)
- (ivy--insert-minibuffer "")
- (ivy--exhibit)))
- (if (string-match "exited abnormally with code \\([0-9]+\\)\n" 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)))))
+ (let ((cands
+ (cond ((string= event "finished\n")
+ (with-current-buffer (process-buffer process)
+ (split-string
+ (buffer-string)
+ counsel-async-split-string-re
+ t)))
+ ((string-match "exited abnormally with code \\([0-9]+\\)\n"
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)))
+ (list
+ (or exit-code
+ (format "error code %d" exit-num))))))))
+ (cond ((string= event "finished\n")
+ (ivy--set-candidates
+ (ivy--sort-maybe
+ cands))
+ (if (null ivy--old-cands)
+ (setq ivy--index
+ (or (ivy--preselect-index
+ (ivy-state-preselect ivy-last)
+ ivy--all-candidates)
+ 0))
+ (let ((re (funcall ivy--regex-function ivy-text)))
+ (unless (stringp re)
+ (setq re (caar re)))
+ (ivy--recompute-index
+ ivy-text re ivy--all-candidates)))
+ (setq ivy--old-cands ivy--all-candidates)
+ (if (null ivy--all-candidates)
+ (ivy--insert-minibuffer "")
+ (ivy--exhibit)))
+ ((string-match "exited abnormally with code \\([0-9]+\\)\n" event)
+ (setq ivy--all-candidates cands)
+ (setq ivy--old-cands ivy--all-candidates)
+ (ivy--exhibit)))))
(defun counsel--async-filter (process str)
"Receive from PROCESS the output STR.
- [elpa] master 1c04fb8 126/272: Add ivy-fixed-height-minibuffer, (continued)
- [elpa] master 1c04fb8 126/272: Add ivy-fixed-height-minibuffer, Oleh Krehel, 2016/04/25
- [elpa] master 7a0b243 130/272: Give ivy-read-read-action enough minibuffer space, Oleh Krehel, 2016/04/25
- [elpa] master 708ca11 141/272: ivy.el: Fix a few face declarations, Oleh Krehel, 2016/04/25
- [elpa] master f647bca 136/272: Simplify the ivy-format-function interface, Oleh Krehel, 2016/04/25
- [elpa] master c2b330b 091/272: doc/ivy.org: Add @vindex and @kindex automatically, Oleh Krehel, 2016/04/25
- [elpa] master 4c99ec6 107/272: counsel.el: Shuffle functions, Oleh Krehel, 2016/04/25
- [elpa] master 0fd6a75 142/272: Move switch-to-buffer to :display-transformer-fn, Oleh Krehel, 2016/04/25
- [elpa] master f5a21db 157/272: ivy.el: define setq-local and defvar-local unless defined, Oleh Krehel, 2016/04/25
- [elpa] master 71644d9 190/272: ivy.el (ivy-read): Remove code that sets action index to 1, Oleh Krehel, 2016/04/25
- [elpa] master 220fd38 079/272: doc/ivy.org: Improve the markup, Oleh Krehel, 2016/04/25
- [elpa] master 50f3092 169/272: counsel.el (counsel--async-sentinel): Start refactor,
Oleh Krehel <=
- [elpa] master 41b8b0d 113/272: ivy.el (ivy-occur): Add a warning, Oleh Krehel, 2016/04/25
- [elpa] master b39e449 228/272: counsel.el (counsel-ag-map): Add, Oleh Krehel, 2016/04/25
- [elpa] master 79f9cda 165/272: counsel-ag: Fix escaping problem, Oleh Krehel, 2016/04/25
- [elpa] master f1c7233 164/272: swiper.el (swiper-occur): Bind ivy--regex-function, Oleh Krehel, 2016/04/25
- [elpa] master 1de78f3 160/272: Improve window handling for ivy-occur, Oleh Krehel, 2016/04/25
- [elpa] master c90784d 087/272: doc/ivy.org: Update, Oleh Krehel, 2016/04/25
- [elpa] master d085765 146/272: ivy.el (ivy-switch-buffer): Don't fall back to switch-to-buffer, Oleh Krehel, 2016/04/25
- [elpa] master be06ae0 163/272: swiper.el: Add docstring, Oleh Krehel, 2016/04/25
- [elpa] master 587526e 138/272: counsel.el (counsel-git-grep-transformer): New defun, Oleh Krehel, 2016/04/25
- [elpa] master d40bdab 134/272: doc/ivy.org: Fix typo, Oleh Krehel, 2016/04/25