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?
Asked
Active
Viewed 1,479 times
4 Answers
12
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)))))

scottfrazer
- 17,079
- 4
- 51
- 49
2
You can do M-x blink-matching-open RET
and if you like to use it often, bind it to a key.

Stefan
- 27,908
- 4
- 53
- 82
1
scotfrazer's answer works great for parens, braces etc, but if you need to match ruby def...end or class...end delimiters (or similar in other languages) this answer from emacs.stackexchange works great:
(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))
The matching (off-page) delimiter will be highlighted if you pause the cursor on a delimiter for .5 seconds or longer.
0
You can install the Mic Paren (available on MELPA: M-x package-install mic-paren
) and activate it with M-x paren-activate

Vincent de Lagabbe
- 4,964
- 3
- 31
- 38