summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThanos Apollo <[email protected]>2023-12-30 15:46:47 +0200
committerThanos Apollo <[email protected]>2023-12-30 15:46:47 +0200
commit0ba00bd3fb1ea9d51c701a5fd2a363130be7a852 (patch)
tree6a74897f851b06490b11559b518c7882c8e01bd2
parent3fc932c03d46c4393cfbea6662ee810729044192 (diff)
gnosis-tag-prompt: fix optional values
- Fix prompt formatting issues - Add optional match value, by default nil - This is used to require match for suspending/reviewing specific notes, match should be nil only when adding new notes
-rw-r--r--gnosis.el22
1 files changed, 13 insertions, 9 deletions
diff --git a/gnosis.el b/gnosis.el
index df7c796..3a8b23d 100644
--- a/gnosis.el
+++ b/gnosis.el
@@ -279,7 +279,7 @@ When called with a prefix, unsuspends all notes in deck."
(defun gnosis-suspend-tag ()
"Suspend all note(s) with tag."
- (let ((notes (gnosis-select-by-tag (gnosis-tag-prompt)))
+ (let ((notes (gnosis-select-by-tag (gnosis-tag-prompt nil t)))
(suspend (if current-prefix-arg 0 1)))
(cl-loop for note in notes
do (gnosis-update 'review-log `(= suspend ,suspend) `(= id ,note)))))
@@ -504,17 +504,21 @@ Optionally, add cusotm PROMPT."
t
nil))
-(defun gnosis-tag-prompt (&optional prompt)
- "PROMPT user to select tags, or add new, until they enter `q'.
+(defun gnosis-tag-prompt (&optional prompt match)
+ "PROMPT user to select tags, until they enter `q'.
+Prompt user to select tags, generated from `gnosis-get-tags--unique'.
-Returns a list of unique entered tags."
- (interactive)
+PROMPT: Prompt string value
+MATCH: Require match, t or nil value
+
+Returns a list of unique tags."
(let* ((tags '())
(tag "")
- (prompt (or (concat prompt " (q for quit): ")
- (format "Select tags [%s] (q for quit): " tags))))
+ (prompt (or prompt "Selected tags"))
+ (match (or match nil)))
(while (not (string= tag "q"))
- (setf tag (completing-read prompt (gnosis-get-tags--unique) nil nil))
+ (setf tag (completing-read (concat prompt (format " %s (q for quit): " tags))
+ (gnosis-get-tags--unique) nil match))
(unless (or (string= tag "q") (member tag tags))
(push tag tags)))
(reverse tags)))
@@ -680,7 +684,7 @@ Used to reveal all clozes left with `gnosis-face-cloze-unanswered' face."
(defun gnosis-review-all-with-tags ()
"Review all note(s) with specified tag(s)."
- (let ((notes (gnosis-select-by-tag (gnosis-tag-prompt)))
+ (let ((notes (gnosis-select-by-tag (gnosis-tag-prompt nil t)))
(note-count 0))
(cl-loop for note in notes
do (progn (gnosis-review-note note)