【问题标题】:Display line of matching bracket in the minibufferminibuffer中匹配括号的显示行
【发布时间】:2012-11-14 13:28:53
【问题描述】:

当我在 emacs 中键入右括号时,迷你缓冲区会显示包含匹配左括号的行。有没有办法在 minibuffer 中显示括号、括号等的匹配行而不删除括号并重新输入?

【问题讨论】:

    标签: emacs minibuffer


    【解决方案1】:

    我假设您已打开 show-paren-mode,因此匹配的括号会突出显示:

    (show-paren-mode t)
    

    如果括号不在屏幕上,这将显示匹配的行:

    (defadvice show-paren-function (after my-echo-paren-matching-line activate)
      "If a matching paren is off-screen, echo the matching line."
      (when (char-equal (char-syntax (char-before (point))) ?\))
        (let ((matching-text (blink-matching-open)))
          (when matching-text
            (message matching-text)))))
    

    【讨论】:

      【解决方案2】:

      你可以M-x blink-matching-open RET,如果你喜欢经常使用它,把它绑定到一个键上。

      【讨论】:

        【解决方案3】:

        scotfrazer 的答案非常适合括号、大括号等,但如果您需要匹配来自 emacs.stackexchange 的 ruby​​ def...end 或 class...end 分隔符(或类似的其他语言)this answer,效果很好:

        (defvar match-paren--idle-timer nil)
        (defvar match-paren--delay 0.5)
        (setq match-paren--idle-timer 
             (run-with-idle-timer match-paren--delay t #'blink-matching-open))
        

        如果您将光标停在分隔符上 0.5 秒或更长时间,匹配的(页外)分隔符将突出显示。

        【讨论】:

          【解决方案4】:

          您可以安装Mic Paren(在 MELPA 上可用:M-x package-install mic-paren)并使用M-x paren-activate 激活它

          【讨论】:

            猜你喜欢
            • 2021-10-05
            • 2014-05-01
            • 2015-08-21
            • 2010-09-18
            • 1970-01-01
            • 2015-08-17
            • 1970-01-01
            • 2020-08-25
            • 1970-01-01
            相关资源
            最近更新 更多