0

I have this piece that indicates an opening parenthesis by blinking it.

Currently, if I want to mark an opening parenthesis, I have to do call M-x rk-blink-matching-open each time. I would like the blinking an a matching parenthesis to happen automatically, whenever the cursor is near an opening or closing parentheses.

    (defun rk-blink-matching-open ()
      "Indicate momentarily the start of parenthesized sexp before point."
      (interactive)
    
      (let ((blink-matching-paren-distance
             (buffer-size))
            (blink-matching-paren t))
        (blink-matching-open)))

6
  • 1
    Your function doesn't work as written. It is infinitely recursive - the last line calls the function again.
    – Tyler
    Mar 23, 2022 at 18:33
  • You are correct, so I updated the function name.
    – Dilna
    Mar 23, 2022 at 19:27
  • 1
    "Make it permanent?" You mean save it to your init file?
    – phils
    Mar 23, 2022 at 20:29
  • What @phils asked - what do you mean by make a function permanent?
    – Drew
    Mar 23, 2022 at 20:35
  • Currently, if I want to mark the opening parenthesis, I have to do M-x rk-blink-matching-open each time. I would like that as move through the text, the opening or closing parentheses blink when the cursor is near them.
    – Dilna
    Mar 23, 2022 at 23:24

1 Answer 1

0

Are you not perhaps looking for show-paren-mode?

docstring:

Toggle visualization of matching parens (Show Paren mode).

If called interactively, enable Show-Paren mode if ARG is positive,
and disable it if ARG is zero or negative.  If called from Lisp, also
enable the mode if ARG is omitted or nil, and toggle it if ARG is
toggle; disable the mode otherwise.

Show Paren mode is a global minor mode.  When enabled, any
matching parenthesis is highlighted in show-paren-style after
show-paren-delay seconds of Emacs idle time.

manual: https://www.gnu.org/software/emacs/manual/html_node/emacs/Matching.html

3
  • That is correct. Have noticed that putting the cursor on the opening brace highlights the closing brace. But putting the cursor does not highlight the opening brace. One has to go to the character following the closing brace. Because elisp customarily has many consecutive closing braces, using the consecutive character to highlight the matching opening brace is counter productive.
    – Dilna
    Mar 24, 2022 at 18:48
  • @Veak try setting Show Paren When Point Inside Paren to t. most things are possible, you just have to go looking sometimes
    – user27075
    Mar 24, 2022 at 21:05
  • Consider the following (setq initial-frame-alist '((width . 72) (height . 26)) ). Would expect that putting the cursor in the space between (width . 72) and (height . 26) would highlight the entire (width . 72) (height . 26). But (setq show-paren-when-point-inside-paren t) does not do that. It is very non-intuitive and difficult when debugging because one got to remember suck quirks. Also, if you put the cursor on the parenthesis following (height . 26), only (height . 26) gets highlighted, rather than the entire (height . 26) (height . 26).
    – Dilna
    Mar 24, 2022 at 21:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.