branch: externals/denote
commit e2ba6c144d376548c072c4f7f9452ad22b78bb57
Author: Ashton Wiersdorf <[email protected]>
Commit: Protesilaos Stavrou <[email protected]>

    Guard sorting keywords when given an empty string
    
    I've been using Denote with Transient. However, when `denote' is
    invoked non-interactively (as through a transient prefix) and no
    keywords are specified, the empty string gets passed to `sort', which
    is an error.
    
    I've made a file that can be used with the `elpaca-test' macro from
    the excellent Elpaca package manager to reproduce the bug. I've added
    it as a paste here:
    
        https://paste.sr.ht/~ashton314/66e2fe76478542c745368e82a8eb5c14af38e448
---
 denote.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/denote.el b/denote.el
index 89b2b276a3..a99d02de07 100644
--- a/denote.el
+++ b/denote.el
@@ -1031,7 +1031,7 @@ Return an empty string if the minibuffer input is empty."
 (defun denote-keywords-sort (keywords)
   "Sort KEYWORDS if `denote-sort-keywords' is non-nil.
 KEYWORDS is a list of strings, per `denote-keywords-prompt'."
-  (if denote-sort-keywords
+  (if (and (listp keywords) denote-sort-keywords)
       (sort keywords #'string-collate-lessp)
     keywords))
 

Reply via email to