【问题标题】:In Emacs, is there a way to auto-complete only from one specified buffer?在 Emacs 中,有没有办法只从一个指定的缓冲区自动完成?
【发布时间】:2012-04-12 00:49:30
【问题描述】:

使用 M-/ 时,当前缓冲区中的文本会自动完成,并带有所有活动缓冲区中的建议。

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

【问题讨论】:

    标签: emacs autocomplete


    【解决方案1】:

    假设您正在谈论dabbrev-expandM-/ 是通常的绑定),那么根据您的要求有多种选择。

    要只搜索特定的缓冲区白名单,最简单的方法是设置变量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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-06-02
      • 1970-01-01
      • 1970-01-01
      • 2011-06-22
      • 2015-10-06
      • 2014-02-08
      • 2023-03-08
      相关资源
      最近更新 更多