Android Debug Bridge (adb) device - no permissions
Effective STL 阅读笔记: Item 3: Make copying cheap and correct for objects in containers

Adding Completion to (interactive)

tubo posted @ 2014年9月03日 00:10 in 未分类 , 217 阅读



Adding Completion to (interactive)

Author: Tubo


Is there any way to add my own completion to an (interactive) elisp function? Ideally, I'd
like to pass it a list of strings that it would tab-complete from. I know that using (interactive "D"), (interactive "F") or (interactive "b") give you completion for directories, files and buffer-names respectively, but what about more general inputs?


The argument to interactive need not be a string; if it isn't, it's evaluated to get the list of arguments to pass to the function. Therefore, you can do something like this:
(defun insert-foo-bar-or-baz (arg)
    (completing-read "Choose one: " '("foo" "bar" "baz"))))
  (insert arg))

登录 *

loading captcha image...
or Ctrl+Enter