[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master e953099 89/90: Make counsel-locate use a process
From: |
Oleh Krehel |
Subject: |
[elpa] master e953099 89/90: Make counsel-locate use a process |
Date: |
Tue, 30 Jun 2015 07:29:42 +0000 |
branch: master
commit e9530990914c1d81889269b4a8365b8003625557
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Make counsel-locate use a process
* counsel.el (counsel-locate-function): Update.
(counsel--async-command): New defun.
(counsel--async-sentinel): New defun.
(counsel-locate): Switch to :action, thus allowing "C-M-n" and `ivy-resume'.
* swiper.el: Bump version.
---
counsel.el | 37 ++++++++++++++++++++++++++++++++-----
swiper.el | 2 +-
2 files changed, 33 insertions(+), 6 deletions(-)
diff --git a/counsel.el b/counsel.el
index acc4ca5..94c8608 100644
--- a/counsel.el
+++ b/counsel.el
@@ -401,16 +401,43 @@ Skip some dotfiles unless `ivy-text' requires them."
(if (< (length str) 3)
(list ""
(format "%d chars more" (- 3 (length ivy-text))))
- (split-string
- (shell-command-to-string (concat "locate -i -l 20 --regex " (ivy--regex
str))) "\n" t)))
+ (counsel--async-command
+ (concat "locate -i --regex " (ivy--regex str)))))
+
+(defun counsel--async-command (cmd)
+ (let* ((counsel--process " *counsel*")
+ (proc (get-process counsel--process))
+ (buff (get-buffer counsel--process)))
+ (when proc
+ (delete-process proc))
+ (when buff
+ (kill-buffer buff))
+ (setq proc (start-process-shell-command
+ counsel--process
+ counsel--process
+ cmd))
+ (set-process-sentinel proc #'counsel--async-sentinel)))
+
+(defun counsel--async-sentinel (process event)
+ (if (string= event "finished\n")
+ (progn
+ (with-current-buffer (process-buffer process)
+ (setq ivy--all-candidates (split-string (buffer-string) "\n" t))
+ (setq ivy--old-cands ivy--all-candidates))
+ (ivy--insert-minibuffer
+ (ivy--format ivy--all-candidates)))
+ (if (string= event "exited abnormally with code 1\n")
+ (message "Error"))))
;;;###autoload
(defun counsel-locate ()
"Call locate."
(interactive)
- (let ((val (ivy-read "pattern: " 'counsel-locate-function)))
- (when val
- (find-file val))))
+ (ivy-read "pattern: " nil
+ :dynamic-collection #'counsel-locate-function
+ :action (lambda (val)
+ (when val
+ (find-file val)))))
(defun counsel--generic (completion-fn)
"Complete thing at point with COMPLETION-FN."
diff --git a/swiper.el b/swiper.el
index 9ce5864..1975ae2 100644
--- a/swiper.el
+++ b/swiper.el
@@ -4,7 +4,7 @@
;; Author: Oleh Krehel <address@hidden>
;; URL: https://github.com/abo-abo/swiper
-;; Version: 0.4.1
+;; Version: 0.5.1
;; Package-Requires: ((emacs "24.1"))
;; Keywords: matching
- [elpa] master d921875 79/90: counsel.el (counsel-load-theme): New command, (continued)
- [elpa] master d921875 79/90: counsel.el (counsel-load-theme): New command, Oleh Krehel, 2015/06/30
- [elpa] master 017e007 78/90: counsel.el (counsel-M-x): Avoid compilation warning, Oleh Krehel, 2015/06/30
- [elpa] master 64b76c3 81/90: Fixup compilation warnings related to smex, Oleh Krehel, 2015/06/30
- [elpa] master 225e5aa 82/90: Allow to recursively match history with "C-r", Oleh Krehel, 2015/06/30
- [elpa] master dcd0c50 80/90: counsel.el (counsel-unicode-char): Use action-style call, Oleh Krehel, 2015/06/30
- [elpa] master a287f39 84/90: counsel.el (counsel-git-grep-history): New defvar, Oleh Krehel, 2015/06/30
- [elpa] master e072e96 83/90: swiper.el (swiper-history): New defvar, Oleh Krehel, 2015/06/30
- [elpa] master be80798 86/90: Fix the initial input bug introduced with "C-r", Oleh Krehel, 2015/06/30
- [elpa] master 5036f23 87/90: Make counsel-el work with "C-M-n" and "C-M-p", Oleh Krehel, 2015/06/30
- [elpa] master c33bb2d 88/90: ivy-hydra.el (hydra-ivy): Bind "C-o" to be a toggle, Oleh Krehel, 2015/06/30
- [elpa] master e953099 89/90: Make counsel-locate use a process,
Oleh Krehel <=
- [elpa] master e503688 85/90: counsel.el (counsel-find-file): Use `file-name-history', Oleh Krehel, 2015/06/30
- [elpa] master 55e0188 90/90: Merge commit 'e9530990914c1d81889269b4a8365b8003625557' from swiper, Oleh Krehel, 2015/06/30