在Emacs中,有没有办法只从一个指定的缓冲区自动完成?

Pet*_*ter 4 emacs autocomplete

使用时M-/,当前缓冲区中的文本将自动填充所有活动缓冲区中的建议.

有没有办法将建议限制在一个特定的缓冲区?

phi*_*ils 5

假设您正在谈论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."
Run Code Online (Sandbox Code Playgroud)

这是我的自定义模式的示例(我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)))
Run Code Online (Sandbox Code Playgroud)

请注意,还有其他几种方法可以过滤dabbrev将在其中搜索的缓冲区列表.dabbrev自定义组具有以下详细信息:
M-x customize-group RET dabbrev RET