From 55dd12af18a8ee56b5014baf887ad021fc1d0da0 Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Thu, 23 Jan 2020 23:11:45 +0900 Subject: [PATCH] Use string length for ivy sort --- emacs.el | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/emacs.el b/emacs.el index 0372088..a3d0512 100644 --- a/emacs.el +++ b/emacs.el @@ -2664,13 +2664,21 @@ Any output will be written to current buffer." (define-key help-map "o" 'my-counsel-describe-symbol) ) +(defun my-ivy-length (x y) + "Ivy sort to order by string length." + (<= (length (if (consp x) (car x) x)) + (length (if (consp y) (car y) y)))) +;; (my-ivy-length "a" (cons "bc" t)) +;; (my-ivy-length "a" (cons "c" t)) + (with-eval-after-load 'ivy (ivy-configure 'my-counsel-describe-symbol - :sort-fn #'ivy-string<) + :sort-fn 'my-ivy-length) ) (with-eval-after-load 'counsel (ivy-configure 'counsel-M-x - :initial-input "") + :initial-input "" + :sort-fn 'my-ivy-length) )