[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 2d840b8 157/184: ivy.el (ivy-configure): Add :sort-fn
From: |
Oleh Krehel |
Subject: |
[elpa] master 2d840b8 157/184: ivy.el (ivy-configure): Add :sort-fn |
Date: |
Wed, 16 Oct 2019 13:15:13 -0400 (EDT) |
branch: master
commit 2d840b8be54fbc887a6b2a6a8178d27786d1421f
Author: Oleh Krehel <address@hidden>
Commit: Oleh Krehel <address@hidden>
ivy.el (ivy-configure): Add :sort-fn
* ivy.el (ivy-completing-read):
(ivy-completion-in-region): Don't sort by default.
---
counsel.el | 56 ++++++++++++++++++++++++++++++++++----------------------
doc/ivy.org | 8 --------
doc/ivy.texi | 22 +++++-----------------
ivy.el | 14 +++++---------
4 files changed, 44 insertions(+), 56 deletions(-)
diff --git a/counsel.el b/counsel.el
index 28575a0..5380029 100644
--- a/counsel.el
+++ b/counsel.el
@@ -555,14 +555,14 @@ Variables declared using `defcustom' are highlighted
according to
:history 'counsel-describe-symbol-history
:keymap counsel-describe-map
:preselect (ivy-thing-at-point)
- :sort t
:action (lambda (x)
(funcall counsel-describe-variable-function (intern
x)))
:caller 'counsel-describe-variable)))
(ivy-configure 'counsel-describe-variable
:initial-input "^"
- :display-transformer-fn #'counsel-describe-variable-transformer)
+ :display-transformer-fn #'counsel-describe-variable-transformer
+ :sort-fn #'ivy-string<)
;;** `counsel-describe-function'
(ivy-set-actions
@@ -606,14 +606,14 @@ to `ivy-highlight-face'."
:history 'counsel-describe-symbol-history
:keymap counsel-describe-map
:preselect (funcall counsel-describe-function-preselect)
- :sort t
:action (lambda (x)
(funcall counsel-describe-function-function (intern
x)))
:caller 'counsel-describe-function)))
(ivy-configure 'counsel-describe-function
:initial-input "^"
- :display-transformer-fn #'counsel-describe-function-transformer)
+ :display-transformer-fn #'counsel-describe-function-transformer
+ :sort-fn #'ivy-string<)
;;** `counsel-set-variable'
(defvar counsel-set-variable-history nil
@@ -742,7 +742,6 @@ a symbol and how to search for them."
(symbol-plist sym)))
:history 'counsel-apropos-history
:preselect (ivy-thing-at-point)
- :sort t
:action (lambda (pattern)
(when (string= pattern "")
(user-error "Please specify a pattern"))
@@ -757,6 +756,9 @@ a symbol and how to search for them."
(apropos (concat "\\`" pattern "\\'"))))
:caller 'counsel-apropos))
+(ivy-configure 'counsel-apropos
+ :sort-fn #'ivy-string<)
+
;;** `counsel-info-lookup-symbol'
(defvar info-lookup-mode)
(declare-function info-lookup-guess-default "info-look")
@@ -785,11 +787,13 @@ With prefix arg MODE a query for the symbol help mode is
offered."
(list (ivy-read "Describe symbol: " (info-lookup->completions topic
mode)
:history 'info-lookup-history
:preselect (info-lookup-guess-default topic mode)
- :sort t
:caller 'counsel-info-lookup-symbol)
mode))))
(info-lookup-symbol symbol mode))
+(ivy-configure 'counsel-info-lookup-symbol
+ :sort-fn #'ivy-string<)
+
;;** `counsel-M-x'
(defface counsel-key-binding
'((t :inherit font-lock-keyword-face))
@@ -1169,10 +1173,12 @@ back to the face of the character after point, and
finally the
:require-match t
:history 'face-name-history
:preselect (counsel--face-at-point)
- :sort t
:action counsel-describe-face-function
:caller 'counsel-describe-face))
+(ivy-configure 'counsel-describe-face
+ :sort-fn #'ivy-string<)
+
(defun counsel-customize-face (name)
"Customize face with NAME."
(customize-face (intern name)))
@@ -1216,10 +1222,12 @@ selected face."
:require-match t
:history 'face-name-history
:preselect (counsel--face-at-point)
- :sort t
:action counsel-describe-face-function
:caller 'counsel-faces)))
+(ivy-configure 'counsel-faces
+ :sort-fn #'ivy-string<)
+
(add-to-list 'ivy-format-functions-alist '(counsel-faces .
counsel--faces-format-function))
(ivy-set-actions
@@ -2371,13 +2379,15 @@ can use `C-x r j i' to open that file."
(if (eq 'file (cadr register-alist-entry))
(cddr register-alist-entry)))
register-alist)
- :sort t
:require-match t
:history 'counsel-file-register
:caller 'counsel-file-register
:action (lambda (register-file)
(with-ivy-window (find-file register-file)))))
+(ivy-configure 'counsel-file-register
+ :sort-fn #'ivy-string<)
+
(ivy-set-actions
'counsel-file-register
'(("j" find-file-other-window "other window")))
@@ -3765,10 +3775,6 @@ This variable has no effect unless
;;* Misc. Emacs
;;** `counsel-mark-ring'
-(defcustom counsel-mark-ring-sort-selections t
- "If non-nil, sort `mark-ring' list by line number."
- :type 'boolean)
-
(defface counsel--mark-ring-highlight
'((t (:inherit highlight)))
"Face for current `counsel-mark-ring' line."
@@ -3837,7 +3843,6 @@ Obeys `widen-automatically', which see."
(if cands
(ivy-read "Mark: " cands
:require-match t
- :sort counsel-mark-ring-sort-selections
:action (lambda (cand)
(let ((pos (get-text-property 0 'point cand)))
(when pos
@@ -3852,7 +3857,8 @@ Position of selected mark outside accessible part of
buffer")))
(ivy-configure 'counsel-mark-ring
:update-fn #'counsel--mark-ring-update-fn
- :unwind-fn #'counsel--mark-ring-unwind)
+ :unwind-fn #'counsel--mark-ring-unwind
+ :sort-fn #'ivy-string<)
;;** `counsel-package'
(defvar package--initialized)
@@ -3960,8 +3966,7 @@ Additional actions:\\<ivy-minibuffer-map>
(map-keymap (lambda (k v) (tmm-get-keymap (cons k v))) menu)
(setq tmm-km-list (nreverse tmm-km-list))
(setq out (ivy-read "Menu bar: " (tmm--completion-table tmm-km-list)
- :require-match t
- :sort nil))
+ :require-match t))
(setq choice (cdr (assoc out tmm-km-list)))
(setq chosen-string (car choice))
(setq choice (cdr choice))
@@ -4230,11 +4235,13 @@ matching the register's value description against a
regexp in
(list s))))
register-alist)
:require-match t
- :sort t
:history 'counsel-register-history
:action #'counsel-register-action
:caller 'counsel-register))
+(ivy-configure 'counsel-register
+ :sort-fn #'ivy-string<)
+
;;** `counsel-evil-registers'
;;;###autoload
(defun counsel-evil-registers ()
@@ -4881,7 +4888,6 @@ COUNT defaults to 1."
(setq ivy-completion-end (point))
(ivy-read "Unicode name: " counsel--unicode-table
:history 'counsel-unicode-char-history
- :sort t
:action (lambda (name)
(with-ivy-window
(delete-region ivy-completion-beg ivy-completion-end)
@@ -4890,6 +4896,9 @@ COUNT defaults to 1."
(setq ivy-completion-end (point))))
:caller 'counsel-unicode-char))
+(ivy-configure 'counsel-unicode-char
+ :sort-fn #'ivy-string<)
+
(defun counsel-unicode-copy (name)
"Ivy action to copy the unicode from NAME to the kill ring."
(kill-new (char-to-string (get-text-property 0 'code name))))
@@ -5033,10 +5042,12 @@ selected color."
(ivy-read "Web color: " colors
:require-match t
:history 'counsel-colors-web-history
- :sort t
:action #'insert
:caller 'counsel-colors-web)))
+(ivy-configure 'counsel-colors-web
+ :sort-fn #'ivy-string<)
+
(add-to-list 'ivy-format-functions-alist '(counsel-colors-web .
counsel--colors-web-format-function))
(ivy-set-actions
'counsel-colors-web
@@ -5930,11 +5941,12 @@ Additional actions:\\<ivy-minibuffer-map>
(counsel--minor-candidates)
:require-match t
:history 'counsel-minor-history
- :sort t
:action (lambda (x)
(call-interactively (cdr x)))))
-(cl-pushnew '(counsel-minor . "^+") ivy-initial-inputs-alist :key #'car)
+(ivy-configure 'counsel-minor
+ :initial-input "^+"
+ :sort-fn #'ivy-string<)
(ivy-set-actions
'counsel-minor
diff --git a/doc/ivy.org b/doc/ivy.org
index a2ca1dc..a49569d 100644
--- a/doc/ivy.org
+++ b/doc/ivy.org
@@ -1239,7 +1239,6 @@ later use yourself. However, it's recommended that you
use the
:preselect (ivy-thing-at-point)
:history 'counsel-describe-symbol-history
:require-match t
- :sort t
:action (lambda (x)
(describe-function
(intern x)))
@@ -1260,13 +1259,6 @@ Here are the interesting features of the above function,
in the order that they
separate from the common history in =ivy-history=.
- The =require-match= is set to =t= since it doesn't make sense to
call =describe-function= on an un-interned symbol.
-- The =sort= argument is set to =t= so choosing between similar
- candidates becomes easier. Sometimes, the collection size will
- exceed =ivy-sort-max-size=, which is 30000 by default. In that case
- the sorting will not happen to avoid delays.
-
- Adjust this variable to choose between sorting time and completion
- start-up time.
- The =action= argument calls =describe-function= on the interned
selected candidate.
- The =caller= argument identifies this completion session. This is
diff --git a/doc/ivy.texi b/doc/ivy.texi
index e4813cc..1b4a3b9 100644
--- a/doc/ivy.texi
+++ b/doc/ivy.texi
@@ -24,14 +24,11 @@ Copyright (C) 2015-2019 Free Software Foundation, Inc.
@quotation
Permission is granted to copy, distribute and/or modify this document
-under the terms of the GNU Free Documentation License, Version 1.3 or
-any later version published by the Free Software Foundation; with no
-Invariant Sections, with the Front-Cover Texts being ``A GNU Manual,''
-and with the Back-Cover Texts as in (a) below. A copy of the license
-is included in the section entitled ``GNU Free Documentation License.''
-
-(a) The FSF's Back-Cover Text is: ``You have the freedom to copy and
-modify this GNU manual.''
+under the terms of the GNU Free Documentation License, Version 1.3
+or any later version published by the Free Software Foundation;
+with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
+A copy of the license is included in the section entitled "GNU
+Free Documentation License".
@end quotation
@end copying
@@ -1639,7 +1636,6 @@ later use yourself. However, it's recommended that you
use the
:preselect (ivy-thing-at-point)
:history 'counsel-describe-symbol-history
:require-match t
- :sort t
:action (lambda (x)
(describe-function
(intern x)))
@@ -1668,14 +1664,6 @@ separate from the common history in @code{ivy-history}.
The @code{require-match} is set to @code{t} since it doesn't make sense to
call @code{describe-function} on an un-interned symbol.
@item
-The @code{sort} argument is set to @code{t} so choosing between similar
-candidates becomes easier. Sometimes, the collection size will
-exceed @code{ivy-sort-max-size}, which is 30000 by default. In that case
-the sorting will not happen to avoid delays.
-
-Adjust this variable to choose between sorting time and completion
-start-up time.
-@item
The @code{action} argument calls @code{describe-function} on the interned
selected candidate.
@item
diff --git a/ivy.el b/ivy.el
index fa78cf0..1527e85 100644
--- a/ivy.el
+++ b/ivy.el
@@ -1774,13 +1774,7 @@ This function is suitable as a replacement for
(if (consp y) (car y) y)))
(defcustom ivy-sort-functions-alist
- '((read-file-name-internal . ivy-sort-file-function-default)
- (internal-complete-buffer . nil)
- (ivy-completion-in-region . nil)
- (counsel-git-grep-function . nil)
- (Man-goto-section . nil)
- (org-refile . nil)
- (t . ivy-string<))
+ '((t . ivy-string<))
"An alist of sorting functions for each collection function.
Interactive functions that call completion fit in here as well.
@@ -1918,6 +1912,7 @@ May supersede `ivy-initial-inputs-alist'."
update-fn
unwind-fn
index-fn
+ sort-fn
display-transformer-fn
more-chars
grep-p)
@@ -1933,6 +1928,8 @@ May supersede `ivy-initial-inputs-alist'."
(ivy--alist-set 'ivy-unwind-fns-alist caller unwind-fn))
(when index-fn
(ivy--alist-set 'ivy-index-functions-alist caller index-fn))
+ (when sort-fn
+ (ivy--alist-set 'ivy-sort-functions-alist caller sort-fn))
(when display-transformer-fn
(ivy-set-display-transformer caller display-transformer-fn))
(when more-chars
@@ -2427,7 +2424,6 @@ INHERIT-INPUT-METHOD is currently ignored."
:def def
:history history
:keymap nil
- :sort t
:dynamic-collection ivy-completing-read-dynamic-collection
:caller (if (and collection (symbolp collection))
collection
@@ -2551,7 +2547,6 @@ See `completion-in-region' for further information."
;; `completion-all-completions'.
:predicate nil
:initial-input initial
- :sort t
:action #'ivy-completion-in-region-action
:unwind (lambda ()
(unless (eq ivy-exit 'done)
@@ -5052,6 +5047,7 @@ make decisions based on the whole marked list."
(funcall ffap-url-fetcher url))
(ivy-configure 'read-file-name-internal
+ :sort-fn #'ivy-sort-file-function-default
:display-transformer-fn #'ivy-read-file-transformer)
(ivy-configure 'internal-complete-buffer
- [elpa] master 84e1ab8 117/184: counsel.el (counsel-package): Refresh contents automatically, (continued)
- [elpa] master 84e1ab8 117/184: counsel.el (counsel-package): Refresh contents automatically, Oleh Krehel, 2019/10/16
- [elpa] master 9d3d7de 132/184: counsel.el (counsel-slime-repl-history): Add., Oleh Krehel, 2019/10/16
- [elpa] master 9e1b9a0 131/184: counsel.el (counsel-google-function): Add missing require, Oleh Krehel, 2019/10/16
- [elpa] master 5ff8b5e 133/184: ivy.el (ivy-completion-in-region-action): Use declare-function., Oleh Krehel, 2019/10/16
- [elpa] master 78dd554 134/184: ivy.el (ivy--exhibit): Handle ivy--reset-state initial call, Oleh Krehel, 2019/10/16
- [elpa] master c1ea2af 145/184: ivy.el (ivy-read): Fix conflict an existing read-key session, Oleh Krehel, 2019/10/16
- [elpa] master 589e03f 144/184: ivy.el (ivy-configure): Use for ivy-index-functions-alist, Oleh Krehel, 2019/10/16
- [elpa] master 64c0804 163/184: ivy.el (ivy-partial-or-done): Work with completion-cycle-threshold, Oleh Krehel, 2019/10/16
- [elpa] master 6f23c5e 152/184: ivy.el (ivy-occur-press): Re-use ivy-highlight-grep-commands, Oleh Krehel, 2019/10/16
- [elpa] master f46cdad 154/184: counsel.el (counsel-grep): Add :require-match, Oleh Krehel, 2019/10/16
- [elpa] master 2d840b8 157/184: ivy.el (ivy-configure): Add :sort-fn,
Oleh Krehel <=
- [elpa] master f0451db 173/184: ivy.el (ivy-occur-revert-buffer): Don't error if the swiper buffer was killed, Oleh Krehel, 2019/10/16
- [elpa] master 3bd1d87 182/184: counsel.el (counsel-locate-cmd-es): Encode command to local codepage, Oleh Krehel, 2019/10/16
- [elpa] master 8b4693c 169/184: counsel.el (counsel-imenu-action and -get-canditates-from): Revert., Oleh Krehel, 2019/10/16
- [elpa] master 882d6c4 161/184: counsel.el (counsel-imenu): Work with :update-fn 'auto, Oleh Krehel, 2019/10/16
- [elpa] master 1a9002b 168/184: ivy.el: Clean up obsolete aliases, Oleh Krehel, 2019/10/16
- [elpa] master c2d3a4c 184/184: Merge commit 'cd634c6f51458f81898ecf2821ac3169cb65a1eb' from ivy, Oleh Krehel, 2019/10/16
- [elpa] master 12f4771 124/184: ivy.el (ivy-completion-in-region): Add workaround for package-menu-filter, Oleh Krehel, 2019/10/16
- [elpa] master 2b974b4 139/184: ivy.el (ivy-update-fns-alist): New defcustom, Oleh Krehel, 2019/10/16
- [elpa] master 57e0b94 146/184: swiper.el (swiper--action): Set case-fold-search, Oleh Krehel, 2019/10/16
- [elpa] master cdca2fc 141/184: counsel.el (counsel-switch-buffer): Re-use ivy-switch-buffer, Oleh Krehel, 2019/10/16