1

For example, suppose I have something like

(defn my-function []
  ..
  ..really long function body..
  ..)

When I scroll to the bottom and type the final ), the Emacs status bar says:

Matches (defn my-function []

which is super helpful. But if I just cursor to after the final ) (with show-paren-mode), it only highlights the opening paren, which is useless if it's scrolled off-screen.

Is there an easy way to get Emacs to show the "Matches ..." line without erasing and re-typing the final paren?

  • Not an answer to your question, but -- if you haven't done so already, you may wish to take a look at the libraries of highlight-parentheses and rainbow-delimiters. I made an unofficial custom modification to highlight-parentheses that permits scrolling off screen -- i.e., scrolling does not delete the highlighted parentheses overlays when using the modification: stackoverflow.com/a/25269210/2112489 – lawlist Sep 12 '14 at 0:59
2

Use the package mic-paren available from MELPA. It supercedes show-paren-mode so you can remove your existing configuration. After you install it calling customize-group mic-paren-matching allows you to customize it to your liking. The setting you want is Paren Highlight OffScreen which you should set to t. If you want to do the same from init file, the relevant elisp is

(paren-activate) ;; activates mic-paren
(setq paren-highlight-offscreen t) 

paren-activate is an interactive command so you can call it from M-x as well. It activates mic-paren and deactivates show-paren-mode

  • Follow-up question: this works great (thank you!) if I run those two function calls by hand, after Emacs has started. If I put them in my .emacs, though, it complains: "Symbol's function definition is void: paren-activate". I've installed via MELPA (it's in ~/.emacs.d/elpa/mic-paren-3.8), and I see mic-paren has an autoload defined for paren-activate. Other autoloads in ~/.emacs.d/elpa/ seem to work fine. Is there something I should do to load things in a different order? – Ken Oct 16 '14 at 21:13
  • Put a call to (package-initialize) before calling (paren-activate). This will enable all the packages and their autoloads. Emacs automatically initializes all the packages after loading the init file, but here we are calling mic-paren before this happens. In general, you will need to do this for configuring any package during init itself. – Vamsi Oct 16 '14 at 22:53
  • There is also a Emacs beta in Stack Exchange now. These would be ontopic and get more useful eyeballs there – Vamsi Oct 16 '14 at 23:00
  • Thanks! That works. And I'm going to check out the Emacs SE now. – Ken Oct 17 '14 at 1:06
  • Thank you! With show-paren-mode I could only get a brief 2 seconds offscreen parens description of match location by M-x toggling blink-matching-open, while with mic-paren the description display in the echo area is persistent and more informative as it shows the number of lines distance to the matching parens above. However, I still wonder if it's somehow possible to get this offscreen feature working with just show-paren-mode. – Robert Nov 11 '18 at 9:01

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.