emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 6ae91f7 213/272: Make ivy-set-sources work also for sync c


From: Oleh Krehel
Subject: [elpa] master 6ae91f7 213/272: Make ivy-set-sources work also for sync completion
Date: Mon, 25 Apr 2016 10:13:26 +0000

branch: master
commit 6ae91f76f4ac653eaecc3765b917bbd181ef3f0d
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>

    Make ivy-set-sources work also for sync completion
    
    Here's a contrived example of how to use it:
    
        (defun my-extra-source ()
          (append
           (when (eq 'Git (vc-backend (buffer-file-name)))
             (list "git1" "git2" "git3"))
           (when (file-exists-p "doc/Changelog.org")
             (list (propertize "doc/Changelog.org" 'face '(:background 
"red"))))))
    
        (defun my-find-file ()
          (interactive)
          (ivy-read "Find file: " 'read-file-name-internal
                    :action (lambda (x)
                              (with-ivy-window
                                (find-file (expand-file-name x 
ivy--directory))))
                    :require-match 'confirm-after-completion
                    :history 'file-name-history
                    :caller 'my-find-file))
    
        (ivy-set-sources
         'my-find-file
         '((my-extra-source)
           (original-source)))
    
    The function `my-find-file' knows nothing about the extra source, it's
    only purpose is to introduce a :caller to attach things to, as to not to
    mess up e.g. `counsel-find-file'.
    
    The function `my-extra-source' gets called once in `ivy-read' via
    `ivy--reset-state'. It takes no args and returns a list of strings,
    possibly empty.
---
 ivy.el |    1 +
 1 file changed, 1 insertion(+)

diff --git a/ivy.el b/ivy.el
index bd5e276..964a947 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1429,6 +1429,7 @@ This is useful for recursive `ivy-read'."
             (if (and (setq sort-fn (cdr (assoc t ivy-sort-functions-alist)))
                      (<= (length coll) ivy-sort-max-size))
                 (setq coll (cl-sort (copy-sequence coll) sort-fn))))))
+      (setq coll (ivy--set-candidates coll))
       (when preselect
         (unless (or (and require-match
                          (not (eq collection 'internal-complete-buffer)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]