[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/hyperdrive bfbdac1319 08/30: Add: (-dir-toggle-sort-direct
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/hyperdrive bfbdac1319 08/30: Add: (-dir-toggle-sort-direction) Move sort toggle into own function |
Date: |
Wed, 6 Sep 2023 18:59:42 -0400 (EDT) |
branch: elpa/hyperdrive
commit bfbdac1319fcc742711ee20d2faac5140d5482dd
Author: Joseph Turner <joseph@ushin.org>
Commit: Joseph Turner <joseph@ushin.org>
Add: (-dir-toggle-sort-direction) Move sort toggle into own function
---
hyperdrive-dir.el | 23 ++++++++++++++++++++++-
hyperdrive-lib.el | 15 ---------------
2 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/hyperdrive-dir.el b/hyperdrive-dir.el
index 342d6c6135..888084a6f3 100644
--- a/hyperdrive-dir.el
+++ b/hyperdrive-dir.el
@@ -137,6 +137,27 @@ Columns are suffixed with up/down arrows according to
(propertize mtime-header 'face
'hyperdrive-column-header))
(propertize name-header 'face
'hyperdrive-column-header)))))
+(defun hyperdrive-dir-complete-sort ()
+ "Return a value for `hyperdrive-directory-sort' selected with completion."
+ (pcase-let* ((read-answer-short t)
+ (choices (mapcar (lambda (field)
+ (let ((desc (symbol-name (car field))))
+ (list desc (aref desc 0) (format "Sort by
%s" desc))))
+ hyperdrive-dir-sort-fields))
+ (column (intern (read-answer "Sort by column: " choices))))
+ (hyperdrive-dir-toggle-sort-direction column hyperdrive-directory-sort)))
+
+(defun hyperdrive-dir-toggle-sort-direction (column sort)
+ "Return `hyperdrive-directory-sort' cons cell for COLUMN.
+If SORT is already sorted using COLUMN, toggle direction.
+Otherwise, set direction to \\+`:descending'."
+ (pcase-let* ((`(,current-column . ,current-direction) sort)
+ (direction (if (and (eq column current-column)
+ (eq current-direction :ascending))
+ :descending
+ :ascending)))
+ (cons column direction)))
+
(defun hyperdrive-dir-pp (thing)
"Pretty-print THING.
To be used as the pretty-printer for `ewoc-create'."
@@ -286,7 +307,7 @@ Interactively, opens file or directory at point in
"Sort current `hyperdrive-dir' buffer by DIRECTORY-SORT.
DIRECTORY-SORT should be a valid value of
`hyperdrive-directory-sort'."
- (interactive (list (hyperdrive-complete-sort)))
+ (interactive (list (hyperdrive-dir-complete-sort)))
(setq-local hyperdrive-directory-sort directory-sort)
(with-silent-modifications
(let ((entries (ewoc-collect hyperdrive-ewoc #'hyperdrive-entry-p)))
diff --git a/hyperdrive-lib.el b/hyperdrive-lib.el
index 1c689964a4..907fcdc28c 100644
--- a/hyperdrive-lib.el
+++ b/hyperdrive-lib.el
@@ -1035,21 +1035,6 @@ 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* ((read-answer-short t)
- (choices (mapcar (lambda (field)
- (let ((desc (symbol-name (car field))))
- (list desc (aref desc 0) (format "Sort by
%s" desc))))
- hyperdrive-dir-sort-fields))
- (column (intern (read-answer "Sort by column: " choices)))
- (`(,current-column . ,current-direction)
hyperdrive-directory-sort)
- (direction (if (and (eq column current-column)
- (eq current-direction :ascending))
- :descending
- :ascending)))
- (cons column direction)))
-
(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 a39567f697 24/30: Change: (hyperdrive--fill) Use string-match-p, (continued)
- [nongnu] elpa/hyperdrive a39567f697 24/30: Change: (hyperdrive--fill) Use string-match-p, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive 447994e8b2 13/30: Change: (hyperdrive-dir-column-headers) Clickable column headers, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive db30be6a57 28/30: Comment: Update TODO, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive bbd78c6361 23/30: Docs: Update customization option docs, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive 53927eb0a9 25/30: Merge branch 'check-writablep', ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive fcda78fd06 30/30: Merge branch 'dir-sort-clickable', ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive 68ee5c5213 22/30: Meta: Update changelog, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive decf302b97 27/30: Fix: Require url, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive eaf2e5104f 29/30: Comment: Remove TODOs, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive 328635c1f9 07/30: Change: (hyperdrive-directory-sort) Use column name as alist key, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive bfbdac1319 08/30: Add: (-dir-toggle-sort-direction) Move sort toggle into own function,
ELPA Syncer <=
- [nongnu] elpa/hyperdrive ed274229a6 18/30: Comment: Add HACK notice, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive 2f4e5408d4 10/30: Comment: Add TODO, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive 3b79b631a1 09/30: Change: (hyperdrive-dir-column-headers) Don't use glyphs, ELPA Syncer, 2023/09/06
- [nongnu] elpa/hyperdrive 9e8cf738ba 26/30: Tidy, ELPA Syncer, 2023/09/06