Completing read

自动补全功能在任何时候都是受欢迎的,Emacs提供了一个基本的函数completing-read,可以在接受用户输入时提供补全功能。除此之外,我们还可以使用一些更加强大的函数,比如ido里面的ido-completing-read,或者使用iswitchb提供的功能。

使用ido-completing-read比较简单,参见psvn.el。而iswitchb并没有提供一个类似的函数,所以必须自己写一个。

(defun wl-completing-read (prompt choices dummy require-match)
  "Use iswitchb completion functionality."
  (let ((iswitchb-make-buflist-hook
         (lambda ()
           (setq iswitchb-temp-buflist choices))))
    (iswitchb-read-buffer prompt nil require-match)))

(defvar wl-completing-read-function
  (if (fboundp 'iswitchb-read-buffer) 'wl-completing-read 'completing-read))

在引入wl-completing-read-function变量之后,要使用funcall来调用它,而不是直接进行函数调用。

(funcall wl-completing-read-function prompt choice nil t)

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据