diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-05 00:53:01 -0200 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2015-01-05 11:18:29 -0200 |
commit | 065ef960b3fcf80ea68dbcbbcca8c276a2d09b07 (patch) | |
tree | bcfa0bee98f6c147361a88bb6cea0528da1346d1 /sx-tag.el | |
parent | d26df2730db01a4904ad71eb3590b5d90c015767 (diff) |
Move sx--multiple-read to sx-tag-multiple-read
Diffstat (limited to 'sx-tag.el')
-rw-r--r-- | sx-tag.el | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -99,6 +99,39 @@ Return the list of invalid tags in TAGS." :site site)))) (cl-remove-if (lambda (x) (member x result)) tags))) + +;;; Prompt the user for tags. +(defvar sx-tag-history nil + "Tags history for interactive prompts.") + +;;; @TODO: Make it so that hitting BACKSPACE with an empty input +;;; deletes a previously submitted tag. +(defun sx-tag-multiple-read (site prompt &optional initial-value) + "Interactively read a list of tags for SITE. +Call `sx-completing-read' multiple times, until input is empty. +Return a list of tags given by the user. + +PROMPT is a string displayed to the user and should not end with +a space nor a colon. INITIAL-VALUE is a list of already-selected +tags." + (let ((completion-list (sx-tag-list--get site)) + (list initial-value) + input) + (while (not (string= + "" + (setq input (sx-completing-read + (concat prompt " [" + (mapconcat #'identity list ",") + "]: ") + completion-list + (lambda (x) (not (member x list))) + nil + 'require-match + nil + 'sx-tag-history)))) + (push input list)) + list)) + (provide 'sx-tag) ;;; sx-tag.el ends here |