[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 005efce764: Fix face issues in show-paren context overlay (bug#59
From: |
Tassilo Horn |
Subject: |
master 005efce764: Fix face issues in show-paren context overlay (bug#59527) |
Date: |
Thu, 24 Nov 2022 04:54:26 -0500 (EST) |
branch: master
commit 005efce764c50f5fc68be84a7fb52565b9a2d2bc
Author: Tassilo Horn <tsdh@gnu.org>
Commit: Tassilo Horn <tsdh@gnu.org>
Fix face issues in show-paren context overlay (bug#59527)
* lisp/paren.el (show-paren--show-context-in-overlay): Use
show-paren-priority as overlay priority (fixes problem 2 of
bug#59527).
* lisp/simple.el (blink-paren-open-paren-line-string): Ensure the
context lines are font-locked before taking the
buffer-substring (fixes problem 1 of bug#59527).
---
lisp/paren.el | 4 ++++
lisp/simple.el | 60 ++++++++++++++++++++++++++++++++--------------------------
2 files changed, 37 insertions(+), 27 deletions(-)
diff --git a/lisp/paren.el b/lisp/paren.el
index e2c060ceb9..1d7fb1c462 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -410,6 +410,10 @@ It is the default value of `show-paren-data-function'."
(line-end-position))))
(setq show-paren--context-overlay (make-overlay beg end)))
(overlay-put show-paren--context-overlay 'display text)
+ ;; Use the (default very high) `show-paren-priority' ensuring that
+ ;; not other overlays shine through (bug#59527).
+ (overlay-put show-paren--context-overlay 'priority
+ show-paren-priority)
(overlay-put show-paren--context-overlay
'face `(:box
( :line-width (1 . -1)
diff --git a/lisp/simple.el b/lisp/simple.el
index e868736614..893a43b03f 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -9184,33 +9184,39 @@ The function should return non-nil if the two tokens do
not match.")
"Return the line string that contains the openparen at POS."
(save-excursion
(goto-char pos)
- ;; Show what precedes the open in its line, if anything.
- (cond
- ((save-excursion (skip-chars-backward " \t") (not (bolp)))
- (buffer-substring (line-beginning-position)
- (1+ pos)))
- ;; Show what follows the open in its line, if anything.
- ((save-excursion
- (forward-char 1)
- (skip-chars-forward " \t")
- (not (eolp)))
- (buffer-substring pos
- (line-end-position)))
- ;; Otherwise show the previous nonblank line,
- ;; if there is one.
- ((save-excursion (skip-chars-backward "\n \t") (not (bobp)))
- (concat
- (buffer-substring (progn
- (skip-chars-backward "\n \t")
- (line-beginning-position))
- (progn (end-of-line)
- (skip-chars-backward " \t")
- (point)))
- ;; Replace the newline and other whitespace with `...'.
- "..."
- (buffer-substring pos (1+ pos))))
- ;; There is nothing to show except the char itself.
- (t (buffer-substring pos (1+ pos))))))
+ ;; Capture the regions in terms of (beg . end) conses whose
+ ;; buffer-substrings we want to show as a context string. Ensure
+ ;; they are font-locked (bug#59527).
+ (let (regions)
+ ;; Show what precedes the open in its line, if anything.
+ (cond
+ ((save-excursion (skip-chars-backward " \t") (not (bolp)))
+ (setq regions (list (cons (line-beginning-position)
+ (1+ pos)))))
+ ;; Show what follows the open in its line, if anything.
+ ((save-excursion
+ (forward-char 1)
+ (skip-chars-forward " \t")
+ (not (eolp)))
+ (setq regions (list (cons pos (line-end-position)))))
+ ;; Otherwise show the previous nonblank line,
+ ;; if there is one.
+ ((save-excursion (skip-chars-backward "\n \t") (not (bobp)))
+ (setq regions (list (cons (progn
+ (skip-chars-backward "\n \t")
+ (line-beginning-position))
+ (progn (end-of-line)
+ (skip-chars-backward " \t")
+ (point)))
+ (cons pos (1+ pos)))))
+ ;; There is nothing to show except the char itself.
+ (t (setq regions (list (cons pos (1+ pos))))))
+ ;; Ensure we've font-locked the context region.
+ (font-lock-ensure (caar regions) (cdar (last regions)))
+ (mapconcat (lambda (region)
+ (buffer-substring (car region) (cdr region)))
+ regions
+ "..."))))
(defvar blink-paren-function 'blink-matching-open
"Function called, if non-nil, whenever a close parenthesis is inserted.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 005efce764: Fix face issues in show-paren context overlay (bug#59527),
Tassilo Horn <=