[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 473c595 064/348: Facilitate the sorting of cons cell input
From: |
Oleh Krehel |
Subject: |
[elpa] master 473c595 064/348: Facilitate the sorting of cons cell input to ivy-read |
Date: |
Sat, 8 Apr 2017 11:03:26 -0400 (EDT) |
branch: master
commit 473c5958db9fccf4e3281191e5e878e6ce1d04a6
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
Facilitate the sorting of cons cell input to ivy-read
* ivy.el (ivy--reset-state): When an alist is passed to `ivy-read', and
a sorting function is associated via 'caller, the sorting function
will receive two cons cells as arguments, instead of two strings as
usual.
Re #554
Example:
(defvar ivy-sorter-data '(("b 1" . 1) ("a 2" . 2) ("d 0" . 0) ("c 5" . 5)))
(defun isn (a b)
(< (cdr a) (cdr b)))
(add-to-list 'ivy-sort-functions-alist '(ivy-sorter . isn))
(ivy-read "string: " ivy-sorter-data
:sort t
:caller 'ivy-sorter)
---
ivy.el | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/ivy.el b/ivy.el
index f4f590d..4fcabbd 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1499,10 +1499,18 @@ This is useful for recursive `ivy-read'."
(setq coll (ivy--buffer-list "" ivy-use-virtual-buffers
predicate)))
(dynamic-collection
(setq coll (funcall collection ivy-text)))
+ ((and (consp collection) (listp (car collection)))
+ (if (and sort (setq sort-fn (cdr (assoc caller
ivy-sort-functions-alist))))
+ (progn
+ (setq sort nil)
+ (setq coll (mapcar #'car
+ (cl-sort
+ (copy-sequence collection)
+ sort-fn))))
+ (setq coll (all-completions "" collection predicate))))
((or (functionp collection)
(byte-code-function-p collection)
(vectorp collection)
- (and (consp collection) (listp (car collection)))
(hash-table-p collection)
(and (listp collection) (symbolp (car collection))))
(setq coll (all-completions "" collection predicate)))
- [elpa] master de91a77 042/348: swiper.el (swiper-occur): Add require, (continued)
- [elpa] master de91a77 042/348: swiper.el (swiper-occur): Add require, Oleh Krehel, 2017/04/08
- [elpa] master fabcdc0 004/348: doc/Changelog.org: Add custom ids and whitespace in the end, Oleh Krehel, 2017/04/08
- [elpa] master c30a6e2 046/348: ivy.el (ivy-minibuffer-map): Undo remap, Oleh Krehel, 2017/04/08
- [elpa] master 3e1a940 045/348: counsel.el: Fix byte compile warnings, Oleh Krehel, 2017/04/08
- [elpa] master c960de5 047/348: counsel.el (counsel-grep-or-swiper): Don't grep on compressed files, Oleh Krehel, 2017/04/08
- [elpa] master 2776358 059/348: Show current value of the variable in the prompt, Oleh Krehel, 2017/04/08
- [elpa] master beee0b7 048/348: counsel.el (counsel-git): Add better error message, Oleh Krehel, 2017/04/08
- [elpa] master 65948fc 053/348: colir.el (colir-parse-color): Fix color parsing in terminal, Oleh Krehel, 2017/04/08
- [elpa] master e987cef 061/348: counsel.el (counsel-read-setq-expression): Fix Eldoc nag, Oleh Krehel, 2017/04/08
- [elpa] master 0091c8a 058/348: ivy.el (ivy-set-prompt-text-properties-function): New devar, Oleh Krehel, 2017/04/08
- [elpa] master 473c595 064/348: Facilitate the sorting of cons cell input to ivy-read,
Oleh Krehel <=
- [elpa] master 23bd7a4 075/348: counsel.el (counsel-git): Add :caller, Oleh Krehel, 2017/04/08
- [elpa] master 74358c2 070/348: Purge all dependency on helm-rhythmbox, Oleh Krehel, 2017/04/08
- [elpa] master 56aa605 076/348: ivy.el (ivy-add-prompt-count): Refactor from ivy--reset-state, Oleh Krehel, 2017/04/08
- [elpa] master 9c01abf 003/348: doc/Changelog.org: Add hlines, Oleh Krehel, 2017/04/08
- [elpa] master e53f256 087/348: ivy.el (ivy-minibuffer-map): Move ivy-toggle-regexp-quote from "M-q" to "M-r", Oleh Krehel, 2017/04/08
- [elpa] master af5f097 108/348: counsel.el (counsel-locate-action-extern): Make interactive, Oleh Krehel, 2017/04/08
- [elpa] master 0028c8c 106/348: counsel.el (counsel-outline): New command, Oleh Krehel, 2017/04/08
- [elpa] master 1d8b4f8 110/348: ivy.el (ivy-sort-matches-functions-alist): New sorting for ivy-switch-buffer, Oleh Krehel, 2017/04/08
- [elpa] master 027fbac 114/348: swiper.el (swiper-multi-action-2): Fix swiper-all, Oleh Krehel, 2017/04/08
- [elpa] master d6cf677 077/348: ivy.el (ivy-prompt): Add warning, Oleh Krehel, 2017/04/08