branch: externals/ivy-hydra
commit eb83a3cda80c63893dede39c63ab4fd7222eea81
Author: Oleh Krehel <[email protected]>
Commit: Oleh Krehel <[email protected]>
ivy.el (ivy--update-minibuffer): Extract
---
ivy.el | 95 ++++++++++++++++++++++++++++++++++--------------------------------
1 file changed, 49 insertions(+), 46 deletions(-)
diff --git a/ivy.el b/ivy.el
index 3bd7104..cb0a0a1 100644
--- a/ivy.el
+++ b/ivy.el
@@ -3267,52 +3267,55 @@ Should be run via minibuffer `post-command-hook'."
(let ((inhibit-field-text-motion nil))
(constrain-to-field nil (point-max)))
(ivy-set-text (ivy--input))
- (if (ivy-state-dynamic-collection ivy-last)
- ;; while-no-input would cause annoying
- ;; "Waiting for process to die...done" message interruptions
- (let ((inhibit-message t)
- coll in-progress)
- (unless (equal ivy--old-text ivy-text)
- (while-no-input
- (setq coll (funcall (ivy-state-collection ivy-last) ivy-text))
- (when (eq coll 0)
- (setq coll nil)
- (setq ivy--old-re nil)
- (setq in-progress t))
- (setq ivy--all-candidates (ivy--sort-maybe coll))
- (setq ivy--old-text ivy-text)))
- (when (eq ivy--all-candidates 0)
- (setq ivy--all-candidates nil)
- (setq ivy--old-re nil)
- (setq in-progress t))
- (when (or ivy--all-candidates
- (and (not (get-process " *counsel*"))
- (not in-progress)))
- (ivy--set-index-dynamic-collection)
- (ivy--insert-minibuffer
- (ivy--format ivy--all-candidates))))
- (cond (ivy--directory
- (cond ((or (string= "~/" ivy-text)
- (and (string= "~" ivy-text)
- ivy-magic-tilde))
- (ivy--cd (ivy--magic-tilde-directory ivy--directory)))
- ((string-match "/\\'" ivy-text)
- (ivy--magic-file-slash))))
- ((eq (ivy-state-collection ivy-last) #'internal-complete-buffer)
- (when (or (and (string-match "\\` " ivy-text)
- (not (string-match "\\` " ivy--old-text)))
- (and (string-match "\\` " ivy--old-text)
- (not (string-match "\\` " ivy-text))))
- (setq ivy--all-candidates
- (if (= (string-to-char ivy-text) ?\s)
- (ivy--buffer-list " ")
- (ivy--buffer-list "" ivy-use-virtual-buffers)))
- (setq ivy--old-re nil))))
- (ivy--insert-minibuffer
- (with-current-buffer (ivy-state-buffer ivy-last)
- (ivy--format
- (ivy--filter ivy-text ivy--all-candidates))))
- (setq ivy--old-text ivy-text))))
+ (ivy--update-minibuffer)))
+
+(defun ivy--update-minibuffer ()
+ (if (ivy-state-dynamic-collection ivy-last)
+ ;; while-no-input would cause annoying
+ ;; "Waiting for process to die...done" message interruptions
+ (let ((inhibit-message t)
+ coll in-progress)
+ (unless (equal ivy--old-text ivy-text)
+ (while-no-input
+ (setq coll (funcall (ivy-state-collection ivy-last) ivy-text))
+ (when (eq coll 0)
+ (setq coll nil)
+ (setq ivy--old-re nil)
+ (setq in-progress t))
+ (setq ivy--all-candidates (ivy--sort-maybe coll))
+ (setq ivy--old-text ivy-text)))
+ (when (eq ivy--all-candidates 0)
+ (setq ivy--all-candidates nil)
+ (setq ivy--old-re nil)
+ (setq in-progress t))
+ (when (or ivy--all-candidates
+ (and (not (get-process " *counsel*"))
+ (not in-progress)))
+ (ivy--set-index-dynamic-collection)
+ (ivy--insert-minibuffer
+ (ivy--format ivy--all-candidates))))
+ (cond (ivy--directory
+ (cond ((or (string= "~/" ivy-text)
+ (and (string= "~" ivy-text)
+ ivy-magic-tilde))
+ (ivy--cd (ivy--magic-tilde-directory ivy--directory)))
+ ((string-match "/\\'" ivy-text)
+ (ivy--magic-file-slash))))
+ ((eq (ivy-state-collection ivy-last) #'internal-complete-buffer)
+ (when (or (and (string-match "\\` " ivy-text)
+ (not (string-match "\\` " ivy--old-text)))
+ (and (string-match "\\` " ivy--old-text)
+ (not (string-match "\\` " ivy-text))))
+ (setq ivy--all-candidates
+ (if (= (string-to-char ivy-text) ?\s)
+ (ivy--buffer-list " ")
+ (ivy--buffer-list "" ivy-use-virtual-buffers)))
+ (setq ivy--old-re nil))))
+ (ivy--insert-minibuffer
+ (with-current-buffer (ivy-state-buffer ivy-last)
+ (ivy--format
+ (ivy--filter ivy-text ivy--all-candidates))))
+ (setq ivy--old-text ivy-text)))
(defun ivy-display-function-fallback (str)
(let ((buffer-undo-list t))