Emacs 获取ido生成的候选列表

Emacs 获取ido生成的候选列表,emacs,elisp,ido,Emacs,Elisp,Ido,是否可以获取列表并将其保存在变量中? 我跑 ido生成候选列表{two | three}。我想要这样的东西 (setq my-desired-list (ido-completing-read-silent '("one" "two" "three" "four" "five") nil nil "t")) 执行后,my desired list的值为(“二”“三”)。 我对ido使用复杂的设置,它为选择准备了非常特殊的过滤器,我想直接使用结果 变量“ido matches”将包含上次调用id

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

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

(setq my-desired-list (ido-completing-read-silent '("one" "two" "three" "four" "five") nil nil "t"))
执行后,
my desired list
的值为
(“二”“三”)

我对ido使用复杂的设置,它为
选择准备了非常特殊的过滤器,我想直接使用结果

变量“ido matches”将包含上次调用ido完成读取时的匹配项。这就是你想要的:

(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")
我意外地找到了解决方案,它可以用于其他情况,用于不同的交互功能,如
ido完成读取


注意:
eval表达式
应绑定到
M-:

我们是在处理文件、帧还是?函数
ido completing read
在第二个参数中获取任意列表。我可以将其设置为真正的“静默”,例如,不与用户交互吗?哦,我理解。您希望避免让用户按enter键。我必须考虑一下这个问题。临时修改或创建一个类似的函数,改变
ido read internal
中的
ido-read-internal
中的代码
部分,和/或改变或创建不同类型的
ido-make-prompt
?“我只是在转动轮子,大声思考。”谢谢讨论,请看我的答案。我认为它是有用的,需要推广。
(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")
(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")