1

是否可以获取列表并将其保存在变量中?我跑

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

并且 ido 生成候选人列表{two | three}。我想要这样的东西

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

my-desired-list执行后的值为("two" "three")。我对 ido 使用了复杂的设置,它准备了非常特殊的过滤器choices,我想直接使用结果。

4

2 回答 2

1

变量“ido-matches”将包含上次调用 ido-completing-read 的匹配项。所以这就是你想要的:

(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")
于 2013-10-19T06:53:25.753 回答
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"))

该解决方案可用于其他情况,用于不同的交互功能,例如ido-completing-read.

于 2013-10-20T12:23:13.930 回答