diff options
author | Thanos Apollo <[email protected]> | 2024-04-02 16:47:23 +0300 |
---|---|---|
committer | Thanos Apollo <[email protected]> | 2024-04-02 16:47:23 +0300 |
commit | 9160a3d77301505e11793f863c0f96b4c846a407 (patch) | |
tree | f241b4dba40c31ee9de030846d14faa995b22674 | |
parent | 23e699ca71c2c8898f5968e3c27a1ff71cac80b6 (diff) |
gnosis-tag-prompt: Rewrite
Since we are not using gnosis-tag-prompt to input tags for notes, this
was due for a rewrite. This function will be used to select tags,
which could be used to output a note-id collection for specified tags.
-rw-r--r-- | gnosis.el | 35 |
1 files changed, 15 insertions, 20 deletions
@@ -919,30 +919,25 @@ DATE is a list of the form (year month day)." (time-date (encode-time 0 0 0 (nth 2 date) (nth 1 date) (nth 0 date)))) (not (time-less-p time-now time-date)))) - -(cl-defun gnosis-tag-prompt (&key (prompt "Selected tags") (match nil) (due nil)) +(cl-defun gnosis-tag-prompt (&key (prompt "Selected tags:") (due nil)) "PROMPT user to select tags, until they enter `q'. -Prompt user to select tags, generated from `gnosis-get-tags--unique'. +Prompt user to select tags, generated from `gnosis-get-tags--unique'. PROMPT: Prompt string value MATCH: Require match, t or nil value -DUE: if t, return tags for due notes from `gnosis-due-tags'. -Returns a list of unique tags." - (let* ((tags '()) - (tag "") - (use-prev (when gnosis-previous-note-tags - (y-or-n-p (format "Use tags from previous note %s?" gnosis-previous-note-tags))))) - (if use-prev - (setf tags gnosis-previous-note-tags) - (while (not (string= tag "q")) - (setf tag (funcall gnosis-completing-read-function (concat prompt (format " %s (q for quit): " tags)) - (cons "q" (if due (gnosis-review-get-due-tags) - (gnosis-get-tags--unique))) - nil match)) - (unless (or (string= tag "q") (member tag tags)) - (push tag tags)))) - (setf gnosis-previous-note-tags (if use-prev tags (reverse tags))) - (reverse tags))) +DUE: if t, return tags for due notes from `gnosis-due-tags'." + (let ((tags '())) + (cond ((and due (null (gnosis-review-get-due-notes))) + (message "No due notes.")) + (t (cl-loop for tag = (completing-read + (concat prompt (format " (%s) (q for quit): " (mapconcat #'identity tags " "))) + (cons "q" (if due (gnosis-review-get-due-tags) + (gnosis-get-tags--unique))) + nil t) + until (string= tag "q") + unless (member tag tags) + do (push tag tags)) + tags)))) (defun gnosis-hint-prompt (previous-hint &optional prompt) "Prompt user for hint. |