【发布时间】:2012-04-12 00:49:30
【问题描述】:
使用 M-/ 时,当前缓冲区中的文本会自动完成,并带有所有活动缓冲区中的建议。
有没有办法将建议限制在一个特定的缓冲区?
【问题讨论】:
标签: emacs autocomplete
使用 M-/ 时,当前缓冲区中的文本会自动完成,并带有所有活动缓冲区中的建议。
有没有办法将建议限制在一个特定的缓冲区?
【问题讨论】:
标签: emacs autocomplete
假设您正在谈论dabbrev-expand(M-/ 是通常的绑定),那么根据您的要求有多种选择。
要只搜索特定的缓冲区白名单,最简单的方法是设置变量dabbrev-search-these-buffers-only:
"If non-nil, a list of buffers which dabbrev should search.
If this variable is non-nil, dabbrev will only look in these buffers.
It will not even look in the current buffer if it is not a member of
this list."
这是我的自定义模式的一个示例(我将 M-/ 重新绑定到此模式的此函数)
(defun tks-dabbrev-expand (arg)
"Expand either aliases or descriptions, depending on context."
(interactive "*P")
(let* ((candidates
(if (looking-back "^\\S-+")
" *tks-aliases*"
" *tks-descriptions*"))
(dabbrev-search-these-buffers-only (list (get-buffer candidates))))
(dabbrev-expand arg)))
请注意,还有其他几种方法可以过滤 dabbrev 将在其中搜索的缓冲区列表。 dabbrev 自定义组有详细信息:
M-x customize-group RET dabbrev RET
【讨论】: