aboutsummaryrefslogtreecommitdiff
path: root/sx.el
diff options
context:
space:
mode:
authorSean Allred <code@seanallred.com>2015-01-02 12:13:28 -0500
committerSean Allred <code@seanallred.com>2015-01-02 12:13:28 -0500
commit9a420bffcc426b4826f14ad1f62b5430750821df (patch)
tree9d5ff1e26d2b8019031895acdb9d030116e35d6f /sx.el
parent51fd9620672ce656a0c660ad9e3a940cc9b435f3 (diff)
parent0325369632523a81e4246533e4067ebd57f7a0e7 (diff)
Merge pull request #183 from vermiculus/search
Search
Diffstat (limited to 'sx.el')
-rw-r--r--sx.el25
1 files changed, 22 insertions, 3 deletions
diff --git a/sx.el b/sx.el
index e2ea914..62484b7 100644
--- a/sx.el
+++ b/sx.el
@@ -74,7 +74,7 @@ DATA can also be the link itself."
"\\1\\2" link))))
(defun sx--ensure-site (data)
- "Add a `site' property to DATA if it doesn't have one. Return DATA.
+ "Add a `site' property to DATA if it doesn't have one. Return DATA.
DATA can be a question, answer, comment, or user (or any object
with a `link' property)."
(when data
@@ -137,7 +137,8 @@ with a `link' property)."
result))
(defmacro sx-assoc-let (alist &rest body)
- "Identical to `let-alist', except `.site' has a special meaning.
+ "Use ALIST with `let-alist' to execute BODY.
+`.site_par' has a special meaning, thanks to `sx--ensure-site'.
If ALIST doesn't have a `site' property, one is created using the
`link' property."
(declare (indent 1) (debug t))
@@ -195,6 +196,24 @@ All ARGS are passed to `completing-read' or `ido-completing-read'."
(apply (if ido-mode #'ido-completing-read #'completing-read)
args))
+(defun sx--multiple-read (prompt hist-var)
+ "Interactively query the user for a list of strings.
+Call `read-string' multiple times, until the input is empty.
+
+PROMPT is a string displayed to the user and should not end with
+a space nor a colon. HIST-VAR is a quoted symbol, indicating a
+list in which to store input history."
+ (let (list input)
+ (while (not (string=
+ ""
+ (setq input (read-string
+ (concat prompt " ["
+ (mapconcat #'identity list ",")
+ "]: ")
+ "" hist-var))))
+ (push input list))
+ list))
+
(defmacro sx-sorted-insert-skip-first (newelt list &optional predicate)
"Inserted NEWELT into LIST sorted by PREDICATE.
This is designed for the (site id id ...) lists. So the first car
@@ -322,7 +341,7 @@ Return the result of BODY."
("ĥ" . "h")
("ĵ" . "j")
("^[:ascii:]" . ""))
- "List of replacements to use for non-ascii characters
+ "List of replacements to use for non-ascii characters.
Used to convert user names into @mentions.")
(defun sx--user-@name (user)