在Emacs中,是否有一种方法只从一个指定的缓冲区自动完成?

4

使用M-/时,当前缓冲区中的文本将自动补全为所有活动缓冲区中的建议。

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

1个回答

5
假设你在谈论(通常绑定为),那么根据你的要求有多种选项。
要仅搜索特定白名单缓冲区,最简单的方法是设置变量:
  "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

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接