Search code examples
emacsminibuffer

Display line of matching bracket in the minibuffer


When I type a close bracket in emacs, the minibuffer shows the line that contains the matching open bracket. Is there a way to display the matching line of a bracket, parenthesis etc in the minibuffer without deleting the bracket and retyping it?


Solution

  • I assume you have turned on show-paren-mode so matching parens are highlighted:

    (show-paren-mode t)
    

    Then this will show the matching line if the paren is off the screen:

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