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, 2015 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, 2015 at 0:30
  • @wasamasa sure, that'd be an acceptable stopgap I suppose.
    – levand
    Oct 13, 2015 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, 2015 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, 2015 at 7:20

2 Answers 2


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.

  • 1
    Cool. This works just how one would hope it would. Hurrah for undocumented features.
    – levand
    Oct 13, 2015 at 15:01
  • Was looking for hl-line face's priority, and turns out there's a similar property to change from -50 to +50 and you're golden. Thanks for the hint!
    – ctietze
    Mar 17, 2022 at 6:37

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)
        (delete-overlay show-paren--overlay)
        (delete-overlay show-paren--overlay-1))

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 and acknowledge you have read our privacy policy.

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