7

I'm using show-paren-mode with expression highlighting, changing the background face to just a shade lighter than the default background. I like it a lot.

The problem is that when I have a mark, the background face from the paren expression is overwriting the background face for the marked region so it looks odd and inconsistent, and it's difficult to visually tell what the whole region is, at a glance.

Is there any way to configure the region face to have a higher "priority" than the show-paren-match face?

  • This is harder than it looks like for a number of reason, would you be OK with advising show-paren-mode to never display something if the region is active instead? – wasamasa Oct 12 '15 at 22:19
  • @wasamasa -- How about setting a lower priority on the overlay that should be covered up? The priority value of the region defined in simple.el is '(nil . 100) -- see redisplay-highlight-region-function – lawlist Oct 13 '15 at 0:30
  • @wasamasa sure, that'd be an acceptable stopgap I suppose. – levand Oct 13 '15 at 1:31
  • @lawlist The documentation states priorities may only be numbers and anything else is for internal use only. Yet the region uses what appears to be a secondary priority which is undocumented. I've tried out values under 100, but they didn't have any effect unless you've set the priority of show-paren to nil which had another side effect: showing the highlighted expression in reverse video. – wasamasa Oct 13 '15 at 7:15
  • @lawlist This could of course be my theme specifying something else than reverse video for the region face, but still, that kind of glitch shouldn't happen in the first place. Hence why I'm proposing an alternative approach. – wasamasa Oct 13 '15 at 7:20
9

Customize option show-paren-priority to have a negative value, e.g., -50.

No, this is not documented anywhere. Yes, a bug was filed about that. No, the bug report was never responded to.

See Emacs bugs #20253, #15899, and #16192.

  • Cool. This works just how one would hope it would. Hurrah for undocumented features. – levand Oct 13 '15 at 15:01
2

As I haven't found a reliable and documented way of altering the respective overlay priorities involved without introducing unwanted visual glitches, I've resorted to advising show-paren-function:

(defadvice show-paren-function (around inhibit-in-region activate)
  (if (region-active-p)
      (progn
        (delete-overlay show-paren--overlay)
        (delete-overlay show-paren--overlay-1))
    ad-do-it))

This merely disables any highlighting if the region happens to be active.

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.