1

Is it possible to get the list and save it in variable? I run

(ido-completing-read "prompt: " '("one" "two" "three" "four" "five") nil nil "t")

and ido generates list of candidates {two | three}. I want something like this

(setq my-desired-list (ido-completing-read-silent '("one" "two" "three" "four" "five") nil nil "t"))

The value of my-desired-list after execution is ("two" "three"). I use complex settings for ido, it prepares very special filters for choices and I want to use the results directly.

artscan
  • 2,340
  • 15
  • 26

2 Answers2

1

The variable `ido-matches' will contain the matched items from the last call to ido-completing-read. So this does what you want:

(defun ido-completing-read-silent (prompt choices initial-input)
  (ido-completing-read prompt choices nil nil initial-input)
  ido-matches)

(ido-completing-read-silent "prompt: " '("one" "two" "three" "four" "five") "t")
;; ("two" "three")
justinhj
  • 11,147
  • 11
  • 58
  • 104
  • Can I make it realy "silent", e.g. without interaction with user? – artscan Oct 19 '13 at 07:14
  • Oh, I understand. You want to avoid having the user press the enter key. I'll have to think about that one. – justinhj Oct 19 '13 at 17:36
  • Temporarily modify, or create a similar function, that alters the section of code `read-from-minibuffer` within `ido-read-internal` and/or alter or create a different type of `ido-make-prompt`? I'm just spinning my wheels and thinking out loud. – lawlist Oct 19 '13 at 22:37
  • 1
    @lawlist thanks for discussion, see my answer. I think it is useful and needs generalization. – artscan Oct 20 '13 at 12:30
1
(defun ido-completing-read-silent (prompt choices initial-input)
  (run-with-timer 0.0001 nil 'exit-minibuffer)
  (ido-completing-read prompt choices nil nil initial-input)
  (mapcar (lambda (x) (flx-propertize x nil)) ido-matches))

(equal (ido-completing-read-silent "prompt: " '("one" "two" "three" "four" "five") "t")
       '("three" "two"))

The solution can be used in another cases, for different interactive functions like ido-completing-read.

artscan
  • 2,340
  • 15
  • 26