[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote 1999217a51 06/10: Make sorting work for missing
|
From: |
ELPA Syncer |
|
Subject: |
[elpa] externals/denote 1999217a51 06/10: Make sorting work for missing components; remove the macro |
|
Date: |
Thu, 30 Nov 2023 00:57:46 -0500 (EST) |
branch: externals/denote
commit 1999217a51b0b809df0f9ac89b6e64b3f35770ea
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Make sorting work for missing components; remove the macro
I am removing the macro because the title sort is a bit different than
the others. This is due to the 'denote-retrieve-filename-title' which
always returns a non-empty string.
---
denote-sort.el | 51 ++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 38 insertions(+), 13 deletions(-)
diff --git a/denote-sort.el b/denote-sort.el
index 138cc0bf68..b6195373af 100644
--- a/denote-sort.el
+++ b/denote-sort.el
@@ -48,20 +48,45 @@
(defvar denote-sort-components '(title keywords signature identifier)
"List of sorting keys applicable for `denote-sort-files' and related.")
-(defmacro denote-sort--define (component)
- "Define Denote sort function for file name COMPONENT."
- `(defun ,(intern (format "denote-sort-%s-lessp" component)) (file1 file2)
- ,(format "Return smallest between FILE1 and FILE2 based on their %s.
+(defun denote-sort-title-lessp (file1 file2)
+ "Return smallest between FILE1 and FILE2 based on their title.
The comparison is done with `denote-sort-comparison-function' between the
-two signature values." component)
- (when-let ((one (,(intern (format "denote-retrieve-filename-%s"
component)) file1))
- (two (,(intern (format "denote-retrieve-filename-%s"
component)) file2))
- (sort (funcall denote-sort-comparison-function one two)))
- file1)))
-
-(denote-sort--define title)
-(denote-sort--define keywords)
-(denote-sort--define signature)
+two title values."
+ (let ((one (denote-retrieve-filename-title file1))
+ (two (denote-retrieve-filename-title file2)))
+ (cond
+ ((string= one (file-name-sans-extension file1))
+ file2)
+ ((or (string= two (file-name-sans-extension file2))
+ (funcall denote-sort-comparison-function one two))
+ file1)
+ (t nil))))
+
+(defun denote-sort-keywords-lessp (file1 file2)
+ "Return smallest between FILE1 and FILE2 based on their keywords.
+The comparison is done with `denote-sort-comparison-function' between the
+two keywords values."
+ (let ((one (denote-retrieve-filename-keywords file1))
+ (two (denote-retrieve-filename-keywords file2)))
+ (cond
+ ((and (string-empty-p one) (not (string-empty-p two))) file2)
+ ((or (and (not (string-empty-p one)) (string-empty-p two))
+ (funcall denote-sort-comparison-function one two))
+ file1)
+ (t nil))))
+
+(defun denote-sort-signature-lessp (file1 file2)
+ "Return smallest between FILE1 and FILE2 based on their signature.
+The comparison is done with `denote-sort-comparison-function' between the
+two signature values."
+ (let ((one (denote-retrieve-filename-signature file1))
+ (two (denote-retrieve-filename-signature file2)))
+ (cond
+ ((and (string-empty-p one) (not (string-empty-p two))) file2)
+ ((or (and (not (string-empty-p one)) (string-empty-p two))
+ (funcall denote-sort-comparison-function one two))
+ file1)
+ (t nil))))
;;;###autoload
(defun denote-sort-files (files component &optional reverse)
- [elpa] externals/denote updated (edeaaa735e -> 97f34bdc0c), ELPA Syncer, 2023/11/30
- [elpa] externals/denote cf3c2b8cbe 03/10: Change the arity of denote-sort-files to make only REVERSE be optional, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 1999217a51 06/10: Make sorting work for missing components; remove the macro,
ELPA Syncer <=
- [elpa] externals/denote 0ed067e5a8 05/10: Rename symbols for consistency; make denote-sort-component-prompt public, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 97f34bdc0c 10/10: Document denote-sort.el, with 'denote-sort-dired' in particular, ELPA Syncer, 2023/11/30
- [elpa] externals/denote db31cca8fa 02/10: Clarify denote-sort-components docstring, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 3cd4999d1c 01/10: Rename denote-sort-files-keys to denote-sort-components; change to list of symbols, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 4050bf6caf 08/10: Fix denote-org-dblock-add-files case of REVERSE without SORT-BY-COMPONENT, ELPA Syncer, 2023/11/30
- [elpa] externals/denote c98e793eef 07/10: Make 'denote-files' Org dynamic block leverage denote-sort, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 1318e4175e 04/10: Tweak denote-sort-files for clarity, ELPA Syncer, 2023/11/30
- [elpa] externals/denote 59f2a61caf 09/10: Document sorting facilities for 'denote-files' Org dynamic block, ELPA Syncer, 2023/11/30