From 230181d271b5bf250bd29fbfcf6660803146f5a0 Mon Sep 17 00:00:00 2001 From: Daniel Radetsky Date: Tue, 27 Aug 2019 16:01:23 -0700 Subject: [PATCH 1/5] add sort by path length & custom method --- projectile.el | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/projectile.el b/projectile.el index 62f989ee4..2b53bb92a 100644 --- a/projectile.el +++ b/projectile.el @@ -251,7 +251,16 @@ is set to 'alien'." (const :tag "Recently opened files" recentf) (const :tag "Recently active buffers, then recently opened files" recently-active) (const :tag "Access time (atime)" access-time) - (const :tag "Modification time (mtime)" modification-time))) + (const :tag "Modification time (mtime)" modification-time) + (const :tag "Path length" path-length) + (const :tag "Custom method" custom-method))) + +(defcustom projectile-sort-custom-method nil + "The sort method to use for custom sorting + +This should be the name of a predicate method usable by `cl-sort'" + :group 'projectile + :type 'symbol) (defcustom projectile-verbose t "Echo messages that are not errors." @@ -2173,7 +2182,9 @@ With a prefix arg INVALIDATE-CACHE invalidates the cache first." (recentf (projectile-sort-by-recentf-first files)) (recently-active (projectile-sort-by-recently-active-first files)) (modification-time (projectile-sort-by-modification-time files)) - (access-time (projectile-sort-by-access-time files)))) + (access-time (projectile-sort-by-access-time files)) + (path-length (projectile-sort-by-path-length files)) + (custom-method (projectile-sort-by-custom-method files)))) (defun projectile-sort-by-recentf-first (files) "Sort FILES by a recent first scheme." @@ -2207,6 +2218,23 @@ With a prefix arg INVALIDATE-CACHE invalidates the cache first." (file2-atime (nth 4 (file-attributes file2)))) (not (time-less-p file1-atime file2-atime))))))) +(defun projectile-sort-by-path-length (files) + "Sort FILES by path length." + (let ((default-directory (projectile-project-root))) + (cl-sort + (copy-sequence files) + (lambda (file1 file2) + (let ((path-len1 (length file1)) + (path-len2 (length file2))) + (< path-len1 path-len2)))))) + +(defun projectile-sort-by-custom-method (files) + "Sort FILES by custom method." + (let ((default-directory (projectile-project-root))) + (cl-sort + (copy-sequence files) + projectile-sort-custom-method))) + ;;;; Find directory in project functionality (defun projectile--find-dir (invalidate-cache &optional dired-variant) From c4079a63d89735306008bf687ce3d102c32baf95 Mon Sep 17 00:00:00 2001 From: Daniel Radetsky Date: Tue, 27 Aug 2019 16:04:43 -0700 Subject: [PATCH 2/5] checkdoc --- projectile.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projectile.el b/projectile.el index 2b53bb92a..a3ff5e6b9 100644 --- a/projectile.el +++ b/projectile.el @@ -256,7 +256,7 @@ is set to 'alien'." (const :tag "Custom method" custom-method))) (defcustom projectile-sort-custom-method nil - "The sort method to use for custom sorting + "The sort method to use for custom sorting. This should be the name of a predicate method usable by `cl-sort'" :group 'projectile From 3561aaf7d082f0c3aa925fe010c27bb051657512 Mon Sep 17 00:00:00 2001 From: Daniel Radetsky Date: Tue, 27 Aug 2019 16:37:34 -0700 Subject: [PATCH 3/5] some docs --- doc/configuration.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doc/configuration.md b/doc/configuration.md index 5c9216a27..59e096267 100644 --- a/doc/configuration.md +++ b/doc/configuration.md @@ -124,6 +124,22 @@ To sort files by