0

Something I like in Emacs is positioning the cursor after the closing brace/paren highlights the opening brace/paren.

Even better, like in Emacs-Lisp mode, the opening ( line is displayed in the minibuffer. This is convenient when that line is too high up and cannot be seen in the display.

In Perl and CPerl mode, however, the opening { line is not shown in the minibuffer. Is there a way to have it shown?

Edit Tried to rename my .emacs / .emacs.d (in case the long config wrote a long time ago would interfere), but that didn't improve anything in these Perl modes.

(using Emacs 26.3 GUI on Ubuntu 18.04 & 20.04)

1

I tried it with emacs -Q on version 26.3 and it works for me: it moves the cursor for a second to the matching opening brace if that is visible and it prints the matching line in the echo area if it is not.

Check the value of post-self-insert-hook with C-h v post-self-insert-hook RET - my setting is:

(electric-indent-post-self-insert-function blink-paren-post-self-insert-function)

If yours is missing the blink-paren-... function, you can add it with

(add-hook 'post-self-insert-hook #'blink-paren-post-self-insert-function)

somewhere in your init file. But you should investigate why you are not getting that: AFAICT, it should be the out-of-the-box default.

The OP indicates that this is already the case in their setup, so we'll have to dig one level deeper. The variable blink-paren-function is used by blink-paren-post-self-insert-function - doing C-h v blink-paren-function RET shows:

Its value is ‘blink-matching-open’

in my case. Now if I place my cursor after the closing brace and do M-x blink-matching-open RET I see the matching line in the echo area.

So check that the variable is set to the function - if not, set it:

(setq blink-paren-function #'blink-matching-open)

and also execute blink-matching-open with the invocation above and check that it produces the appropriate indications

BTW, all of the above was done in a GUI instance of emacs: I did not test in terminal emacs.

| improve this answer | |
  • Interesting, but my post-self-insert-hook var has already that hook value. I renamed my old and well-filled .emacs & .emacs.d before starting Emacs, but that didn't improve anything (and that var is also set in that case). It probably has to do with the Perl and CPerl modes. – e2-e4 Oct 21 at 13:43
  • Edited with a couple of additional things to check. BTW, as long as the hook is set, I don't think Perl/CPerl mode has anything to do with it: I changed the mode to text-mode and I still get the matching blink/message. Ditto for fundamental-mode. – NickD Oct 21 at 14:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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