Fix sorting algorithm of denote-sort-signature-lessp

This commit is contained in:
Protesilaos Stavrou 2023-12-02 07:25:13 +02:00
parent 938a761ae8
commit b13d899c01
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -79,14 +79,17 @@ two keywords values."
"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)))
(let* ((one (denote-retrieve-filename-signature file1))
(two (denote-retrieve-filename-signature file2))
(one-empty-p (string-empty-p one))
(two-empty-p (string-empty-p two)))
(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))))
(one-empty-p
nil)
((and (not one-empty-p) two-empty-p)
one)
(t
(funcall denote-sort-comparison-function one two)))))
;;;###autoload
(defun denote-sort-files (files component &optional reverse)