public
Last active

  • Download Gist
my-util.el
Emacs Lisp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
(defun ido-completing-read-multiple (prompt choices &optional predicate require-match initial-input hist def sentinel)
"Read multiple items with ido-completing-read. Reading stops
when the user enters SENTINEL. By default, SENTINEL is
\"*done*\". SENTINEL is disambiguated with clashing completions
by appending _ to SENTINEL until it becomes unique. So if there
are multiple values that look like SENTINEL, the one with the
most _ at the end is the actual sentinel value. See
documentation for `ido-completing-read' for details on the
other parameters."
(let
((sentinel (if sentinel sentinel "*done*"))
(done-reading nil)
(res ()))
 
;; uniquify the SENTINEL value
(while (find sentinel choices)
(setq sentinel (concat sentinel "_")))
(setq choices (cons sentinel choices))
 
;; read some choices
(while (not done-reading)
(setq this-choice (ido-completing-read prompt choices predicate require-match initial-input hist def))
(if (equal this-choice sentinel)
(setq done-reading t)
(setq res (cons this-choice res))))
 
;; return the result
res
))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.