branch: master commit 76897c0466e97d6f8d222a1d8a820543d2c303fe Author: Oleh Krehel <ohwoeo...@gmail.com> Commit: Oleh Krehel <ohwoeo...@gmail.com>
ivy.el (ivy-sort-functions-alist): Work for commands as well * ivy.el (ivy-sort-functions-alist): Examine `this-command' in addition to the COLLECTION arg of `completing-read'. Add `Man-goto-section' and `org-refile' to the list, since these commands collect the candidates in the order in which they are in the buffer => the candidates must not be sorted. Mention this in the doc. --- ivy.el | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ivy.el b/ivy.el index ca625cc..75953bd 100644 --- a/ivy.el +++ b/ivy.el @@ -594,9 +594,16 @@ Prioritize directories." '((read-file-name-internal . ivy-sort-file-function-default) (internal-complete-buffer . nil) (counsel-git-grep-function . nil) + (Man-goto-section . nil) + (org-refile . nil) (t . string-lessp)) "An alist of sorting functions for each collection function. -For each entry, nil means no sorting. +Interactive functions that call completion fit in here as well. + +For each entry, nil means no sorting. It's very useful to turn +off the sorting for functions that have candidates in the natural +buffer order, like `org-refile' or `Man-goto-section'. + The entry associated to t is used for all fall-through cases.") (defvar ivy-re-builders-alist @@ -835,7 +842,11 @@ The history, defaults and input-method arguments are ignored for now." :preselect (if (listp def) (car def) def) :history history :keymap nil - :sort t)) + :sort + (let ((sort (assoc this-command ivy-sort-functions-alist))) + (if sort + (cdr sort) + t)))) ;;;###autoload (define-minor-mode ivy-mode