在迷你缓冲器中显示匹配支架的线

时间:2012-11-27 00:30:49

标签: emacs minibuffer

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

4 个答案:

答案 0 :(得分:9)

我假设您已启用show-paren-mode,因此突出显示匹配的parens:

(show-paren-mode t)

如果paren离开屏幕,那么这将显示匹配的行:

(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)))))

答案 1 :(得分:2)

您可以执行M-x blink-matching-open RET,如果您想经常使用它,请将其绑定到密钥。

答案 2 :(得分:1)

scotfrazer的答案适用于parens,braces等,但是如果你需要匹配ruby def ... end或class ...来自emacs的结束分隔符(或类似的其他语言)this answer .stackexchange工作得很好:

(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秒或更长时间,匹配(离页)分隔符将突出显示。

答案 3 :(得分:0)

您可以安装Mic Paren(可在MELPA上找到M-x package-install mic-paren)并使用M-x paren-activate

进行激活