使用 M-/时,当前缓冲区中的文本会自动完成,并带有来自所有事件缓冲区的建议。
有没有办法将建议限制在一个特定的缓冲区?
最佳答案
假设您在谈论 dabbrev-expand
(M-/是常用的绑定(bind)方式),那么根据你的要求有多种选择。
要仅搜索特定的缓冲区白名单,最简单的方法是设置变量 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-/
重新绑定(bind)到此模式的此函数)(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
回复 dabbrev
RET
关于emacs - 在 Emacs 中,有没有办法只从一个指定的缓冲区自动完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9907326/