是否可以获取列表并将其保存在变量中? 我跑
(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
准备了非常特殊的过滤器,我想直接使用结果。
答案 0 :(得分:1)
变量`ido-matches'将包含上次调用ido-completed-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")
答案 1 :(得分:1)
(defun eab/wrap-ido-completing-read ()
(interactive)
(ido-completing-read prompt choices nil nil initial-input)
't)
(defun ido-completing-read-silent (prompt choices initial-input)
(execute-kbd-macro (read-kbd-macro "M-: (eab/wrap-ido-completing-read) RET RET"))
ido-matches)
(setq result (ido-completing-read-silent "prompt: " '("one" "two" "three" "four" "five") "t"))
;; result => ("two" "three")
我意外地找到了解决方案,并且可以在其他情况下使用,用于ido-completing-read
等不同的交互功能。
注意:eval-expression
应绑定到M-:
。