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
This commit is contained in:
Ashton Wiersdorf 2023-12-20 10:11:36 +02:00 committed by Protesilaos Stavrou
parent 195f0c3b7f
commit e2ba6c144d
No known key found for this signature in database
GPG key ID: 99BD6459CD5CA3EA

View file

@ -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))