From fdfe617e7378c9af5a294193eb7e204833227334 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Tue, 17 Mar 2026 06:13:54 +0100 Subject: [PATCH] Further improve blink-matching-paren-highlight-offscreen * lisp/simple.el (blink-matching-paren-offscreen): Inherit from show-paren-match face. (blink-paren-open-paren-line-string): Add blink-matching-paren-offscreen face properties to opening paren instead of replacing original fontification. * lisp/paren.el (show-paren-context-when-offscreen): Mention blink-matching-paren-highlight-offscreen in docstring. --- lisp/paren.el | 5 ++++- lisp/simple.el | 23 +++++++---------------- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/lisp/paren.el b/lisp/paren.el index 0a2e47e66a6..1ab3f9a32cf 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -103,7 +103,10 @@ If set to the symbol `child-frame', the context is shown in a child frame at the top-left of the window. You might want to customize the `child-frame-border' face (especially the background color) to give the child frame a distinguished border. -On non-graphical frames, the context is shown in the echo area." +On non-graphical frames, the context is shown in the echo area. + +Note that `blink-matching-paren-highlight-offscreen' can have an +influence on the fontification of the opening offscreen paren." :type '(choice (const :tag "Off" nil) (const :tag "In echo area" t) (const :tag "In overlay" overlay) diff --git a/lisp/simple.el b/lisp/simple.el index b6b729cd9c1..ff7ffafa3a1 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -9528,7 +9528,7 @@ This highlighting uses the `blink-matching-paren-offscreen' face." :group 'paren-blinking) (defface blink-matching-paren-offscreen - '((t :foreground "green")) + '((t :inherit show-paren-match)) "Face for showing in the echo area matched open paren that is off-screen. This face is used only when `blink-matching-paren-highlight-offscreen' is non-nil." @@ -9689,21 +9689,12 @@ face if `blink-matching-paren-highlight-offscreen' is non-nil." (lambda (region) (buffer-substring (car region) (cdr region))) regions - "...")) - (openparen-next-char-idx (1+ openparen-idx))) - (concat - (substring line-string - 0 openparen-idx) - (let ((matched-offscreen-openparen - (substring line-string - openparen-idx openparen-next-char-idx))) - (if blink-matching-paren-highlight-offscreen - (propertize - (substring-no-properties matched-offscreen-openparen) - 'face 'blink-matching-paren-offscreen) - matched-offscreen-openparen)) - (substring line-string - openparen-next-char-idx)))))) + "..."))) + (when blink-matching-paren-highlight-offscreen + (add-face-text-property openparen-idx (1+ openparen-idx) + 'blink-matching-paren-offscreen + nil line-string)) + line-string)))) (defvar blink-paren-function 'blink-matching-open "Function called, if non-nil, whenever a close parenthesis is inserted.