From 776ab59b38814227456b9ccf424b1ccb7bdb7bc2 Mon Sep 17 00:00:00 2001 From: "Basil L. Contovounesios" Date: Fri, 2 Feb 2018 17:14:48 +0000 Subject: [PATCH] Allow users to customise candidate sort order --- counsel-projectile.el | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/counsel-projectile.el b/counsel-projectile.el index 9a0a8a8..3f1e28a 100644 --- a/counsel-projectile.el +++ b/counsel-projectile.el @@ -305,9 +305,13 @@ With a prefix ARG, invalidate the cache first." (projectile-current-project-files) :matcher #'counsel--find-file-matcher :require-match t + :sort t :action counsel-projectile-find-file-action :caller 'counsel-projectile-find-file)) +(unless (assq #'counsel-projectile-find-file ivy-sort-functions-alist) + (push (list #'counsel-projectile-find-file) ivy-sort-functions-alist)) + (ivy-set-display-transformer 'counsel-projectile-find-file 'counsel-projectile-find-file-transformer) @@ -354,9 +358,13 @@ With a prefix ARG, invalidate the cache first." (ivy-read (projectile-prepend-project-name "Find dir: ") (counsel-projectile--project-directories) :require-match t + :sort t :action counsel-projectile-find-dir-action :caller 'counsel-projectile-find-dir)) +(unless (assq #'counsel-projectile-find-dir ivy-sort-functions-alist) + (push (list #'counsel-projectile-find-dir) ivy-sort-functions-alist)) + ;;;; counsel-projectile-switch-to-buffer (defcustom counsel-projectile-remove-current-buffer nil @@ -412,9 +420,13 @@ names as in `ivy--buffer-list', and remove current buffer if (counsel-projectile--project-buffers) :matcher #'ivy--switch-buffer-matcher :require-match t + :sort t :action counsel-projectile-switch-to-buffer-action :caller 'counsel-projectile-switch-to-buffer)) +(unless (assq #'counsel-projectile-switch-to-buffer ivy-sort-functions-alist) + (push (list #'counsel-projectile-switch-to-buffer) ivy-sort-functions-alist)) + (ivy-set-display-transformer 'counsel-projectile-switch-to-buffer 'ivy-switch-buffer-transformer) @@ -1008,8 +1020,12 @@ action." (abbreviate-file-name (projectile-project-root))) :action counsel-projectile-switch-project-action :require-match t + :sort t :caller 'counsel-projectile-switch-project)) +(unless (assq #'counsel-projectile-switch-project ivy-sort-functions-alist) + (push (list #'counsel-projectile-switch-project) ivy-sort-functions-alist)) + ;;;; counsel-projectile (counsel-projectile--defcustom-action @@ -1109,9 +1125,13 @@ If not inside a project, call `counsel-projectile-switch-project'." (counsel-projectile--project-buffers-and-files) :matcher #'counsel-projectile--matcher :require-match t + :sort t :action counsel-projectile-action :caller 'counsel-projectile))) +(unless (assq #'counsel-projectile ivy-sort-functions-alist) + (push (list #'counsel-projectile) ivy-sort-functions-alist)) + (ivy-set-display-transformer 'counsel-projectile 'counsel-projectile-transformer)