[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/denote a59a711f17: Add denote-keywords-sort function
From: |
ELPA Syncer |
Subject: |
[elpa] externals/denote a59a711f17: Add denote-keywords-sort function |
Date: |
Thu, 27 Oct 2022 22:57:31 -0400 (EDT) |
branch: externals/denote
commit a59a711f176723f87d0f3bff283e72b1f22bf4b5
Author: Protesilaos Stavrou <info@protesilaos.com>
Commit: Protesilaos Stavrou <info@protesilaos.com>
Add denote-keywords-sort function
The intent is to abstract the task of sorting the keywords. Before,
it was handled by the 'denote-keywords-prompt', which meant that
keywords were not sorted when the 'denote' function was called from
Lisp.
Thanks to Florian for bringing this matter to my attention:
<https://lists.sr.ht/~protesilaos/denote/%3C166689879712.8.6808878344988686135.71824507%40aboulafia.org%3E>.
---
README.org | 11 ++++++++++-
denote.el | 19 +++++++++++++------
2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/README.org b/README.org
index 7324a27118..3583f04cdf 100644
--- a/README.org
+++ b/README.org
@@ -2430,6 +2430,13 @@ might change them without further notice.
~denote-known-keywords~. Else use only the latter set of keywords
([[#h:6a92a8b5-d766-42cc-8e5b-8dc255466a23][Standard note creation]]).
+#+findex: denote-keywords-sort
++ Function ~denote-keywords-sort~ :: Sort =KEYWORDS= if
+ ~denote-sort-keywords~ is non-nil. =KEYWORDS= is a list of strings,
+ per ~denote-keywords-prompt~. [ This function is part of
+ {{{development-version}}}. Before, the keywords were sorted by the
+ ~denote-keywords-prompt~. ]
+
#+findex: denote-directory
+ Function ~denote-directory~ :: Return path of the variable
~denote-directory~ as a proper directory, also because it accepts a
@@ -2572,7 +2579,9 @@ might change them without further notice.
+ Function ~denote-keywords-prompt~ :: Prompt for one or more
keywords. In the case of multiple entries, those are separated by
the ~crm-sepator~, which typically is a comma. In such a scenario,
- the output is sorted with ~string-lessp~.
+ the output is sorted with ~string-lessp~. To sort the return value,
+ use ~denote-keywords-sort~. [ The ~denote-keywords-sort~ is part of
+ {{{development-version}}}. ]
#+findex: denote-title-prompt
+ Function ~denote-title-prompt~ :: Read file title for ~denote~.
diff --git a/denote.el b/denote.el
index 8a6b2e1d0f..a1a72f7c20 100644
--- a/denote.el
+++ b/denote.el
@@ -731,11 +731,17 @@ keywords."
"Prompt for one or more keywords.
In the case of multiple entries, those are separated by the
`crm-sepator', which typically is a comma. In such a case, the
-output is sorted with `string-lessp'."
- (let ((choice (denote--keywords-crm (denote-keywords))))
- (if denote-sort-keywords
- (sort choice #'string-lessp)
- choice)))
+output is sorted with `string-lessp'.
+
+To sort the return value, use `denote-keywords-sort'."
+ (denote--keywords-crm (denote-keywords)))
+
+(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
+ (sort keywords #'string-lessp)
+ keywords))
(define-obsolete-function-alias
'denote--keywords-prompt
@@ -1380,6 +1386,7 @@ When called from Lisp, all arguments are optional.
(append args nil)))
(let* ((title (or title ""))
(file-type (denote--valid-file-type (or file-type denote-file-type)))
+ (kws (denote--keywords-sort keywords))
(date (if (or (null date) (string-empty-p date))
(current-time)
(denote--valid-date date)))
@@ -1391,7 +1398,7 @@ When called from Lisp, all arguments are optional.
template
(or (alist-get template denote-templates) ""))))
(denote-barf-duplicate-id id)
- (denote--prepare-note title keywords date id directory file-type template)
+ (denote--prepare-note title kws date id directory file-type template)
(denote--keywords-add-to-history keywords)))
(defvar denote--title-history nil
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/denote a59a711f17: Add denote-keywords-sort function,
ELPA Syncer <=