Show parentheses when inside them - Emacs

In emacs, there is a mode show-paren-modethat colors the opposite matching bracket when the cursor is on another. I wrote an example explaining show-paren-mode:

( <-colored colored-> )| <-cursor 

However, this does not work when the cursor is not in the parenthesis:

( <-not colored    cursor inside->|    not colored ->)

How can I enable this? I find that when doing slurpage and barfage in paredit, I cannot track the parentheses very well because they are not colored if I am not on them.

( <-colored     cursor->|     colored-> ) This is optimal

Edit: thanks to the comment from @lawlist, I solved this problem.

+4
source share
2 answers
0

( Emacs ( 25?) ):

(define-advice show-paren-function (:around (fn) fix)
  "Highlight enclosing parens."
  (cond ((looking-at-p "\\s(") (funcall fn))
        (t (save-excursion
             (ignore-errors (backward-up-list))
             (funcall fn)))))
0

Source: https://habr.com/ru/post/1624710/


All Articles