[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive c2af53e72d 07/32: Add: (hyperdrive-dir-sort, hy
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive c2af53e72d 07/32: Add: (hyperdrive-dir-sort, hyperdrive-complete-sort) |
Date: |
Mon, 4 Sep 2023 18:59:34 -0400 (EDT) |
branch: elpa/hyperdrive
commit c2af53e72de8efae4d39bf89e05e7ab60ac67cd6
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Add: (hyperdrive-dir-sort, hyperdrive-complete-sort)
---
hyperdrive-dir.el | 13 +++++++++++++
hyperdrive-lib.el | 24 ++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/hyperdrive-dir.el b/hyperdrive-dir.el
index adf6a51c6b..f2bd3ae6d5 100644
--- a/hyperdrive-dir.el
+++ b/hyperdrive-dir.el
@@ -95,6 +95,7 @@ With point on header, returns directory entry."
"^" #'hyperdrive-up
"D" #'hyperdrive-dir-delete
"H" #'hyperdrive-dir-history
+ "o" #'hyperdrive-dir-sort
"?" #'hyperdrive-describe-hyperdrive)
;; TODO: Get rid of this?
@@ -173,6 +174,18 @@ Interactively, visit file or directory at point in
(interactive (list (hyperdrive-dir--entry-at-point)))
(hyperdrive-history entry))
+(defun hyperdrive-dir-sort (directory-sort)
+ "Sort current `hyperdrive-dir' buffer by DIRECTORY-SORT.
+DIRECTORY-SORT should be a valid value of
+`hyperdrive-directory-sort'."
+ (interactive (list (hyperdrive-complete-sort)))
+ (setq-local hyperdrive-directory-sort directory-sort)
+ (let ((entries (ewoc-collect hyperdrive-ewoc #'hyperdrive-entry-p)))
+ (setf entries (hyperdrive-sort-entries entries))
+ (ewoc-filter hyperdrive-ewoc #'ignore)
+ (dolist (entry entries)
+ (ewoc-enter-last hyperdrive-ewoc entry))))
+
;;;; Imenu support
(defun hyperdrive-dir--imenu-create-index-function ()
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index fa44f07f65..7551330ba1 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -940,6 +940,30 @@ Prompts with PROMPT and DEFAULT, according to
`format-prompt'.
DEFAULT and INITIAL-INPUT are passed to `read-string' as-is."
(read-string (format-prompt prompt default) initial-input
'hyperdrive--name-history default))
+(defun hyperdrive-complete-sort ()
+ "Return a value for `hyperdrive-directory-sort' selected with completion."
+ (pcase-let* ((fn (pcase-lambda (`(cons :tag ,tag (const :format "" ,accessor)
+ (choice :tag "Direction" :value
,_default-direction
+ (const :tag "Ascending"
,ascending-predicate)
+ (const :tag "Descending"
,descending-predicate))))
+ (cons tag (list accessor ascending-predicate
descending-predicate))))
+ (columns (mapcar fn (cdr (get 'hyperdrive-directory-sort
'custom-type))))
+ (read-answer-short t)
+ (choices (cl-loop for (tag . _) in columns
+ for name = (substring tag 3)
+ for key = (aref name 0)
+ collect (cons name (list key tag))))
+ (column-choice (read-answer "Sort by column: " choices))
+ (`(,accessor ,ascending-predicate ,descending-predicate)
+ (map-elt columns (concat "By " column-choice)))
+ (direction-choice (read-answer "Sort in direction: "
+ (list (cons "ascending" (list ?a
"Ascending"))
+ (cons "descending" (list
?d "Descending")))))
+ (predicate (pcase direction-choice
+ ("ascending" ascending-predicate)
+ ("descending" descending-predicate))))
+ (list accessor predicate)))
+
(cl-defun hyperdrive-put-metadata (hyperdrive &key then)
"Put HYPERDRIVE's metadata into the appropriate file, then call THEN."
(declare (indent defun))
- [nongnu] elpa/hyperdrive 0334ccfa0d 01/32: WIP, (continued)
- [nongnu] elpa/hyperdrive 0334ccfa0d 01/32: WIP, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 77c36c870c 16/32: Tidy: (hyperdrive-complete-sort) Use list, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 0478d21827 04/32: WIP, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive beb1f180fa 11/32: Tidy: (hyperdrive-dir-sort) Nest to avoid setf, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 2b1ab2ba8e 15/32: Comment: (hyperdrive-sort-entries) Explain sorting behavior, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive b7bba05ca5 13/32: Fix: (hyperdrive-entry-create) Docstring, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive c56644f9ea 14/32: Tidy: Whitespace, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 45802e59cc 18/32: Fix: (hyperdrive-handler-directory) Ensure buffer-modified-p nil, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive bd440b6465 27/32: Remove: (hyperdrive-column-headers), ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 27c1a81a51 32/32: Merge branch 'wip/dir-sort', ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive c2af53e72d 07/32: Add: (hyperdrive-dir-sort, hyperdrive-complete-sort),
ELPA Syncer <=
- [nongnu] elpa/hyperdrive 994b782630 09/32: Comment: Add TODO, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive aa969e7bf5 10/32: Add: Progress report in footer, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive bf955d34d3 28/32: Add/Change: (hyperdrive-column-headers), ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive de8a963986 05/32: WIP, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive d75559667b 06/32: WIP, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 126f767a46 12/32: Comment: Add TODO, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 7d20ba30ad 19/32: Fix/Change: Use hyperdrive-queue-size everywhere, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive fb915a005c 25/32: Comment: Add TODO, ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 9100b1e748 29/32: Fix: (hyperdrive-column-headers), ELPA Syncer, 2023/09/04
- [nongnu] elpa/hyperdrive 369ec34f4f 21/32: Comment: Remove TODO, ELPA Syncer, 2023/09/04