1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-20 20:50:53 -08:00

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).
This commit is contained in:
Tassilo Horn 2022-11-24 10:47:54 +01:00
parent 8252211833
commit 005efce764
2 changed files with 37 additions and 27 deletions

View file

@ -410,6 +410,10 @@ It is the default value of `show-paren-data-function'."
(line-end-position)))) (line-end-position))))
(setq show-paren--context-overlay (make-overlay beg end))) (setq show-paren--context-overlay (make-overlay beg end)))
(overlay-put show-paren--context-overlay 'display text) (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 (overlay-put show-paren--context-overlay
'face `(:box 'face `(:box
( :line-width (1 . -1) ( :line-width (1 . -1)

View file

@ -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." "Return the line string that contains the openparen at POS."
(save-excursion (save-excursion
(goto-char pos) (goto-char pos)
;; Show what precedes the open in its line, if anything. ;; Capture the regions in terms of (beg . end) conses whose
(cond ;; buffer-substrings we want to show as a context string. Ensure
((save-excursion (skip-chars-backward " \t") (not (bolp))) ;; they are font-locked (bug#59527).
(buffer-substring (line-beginning-position) (let (regions)
(1+ pos))) ;; Show what precedes the open in its line, if anything.
;; Show what follows the open in its line, if anything. (cond
((save-excursion ((save-excursion (skip-chars-backward " \t") (not (bolp)))
(forward-char 1) (setq regions (list (cons (line-beginning-position)
(skip-chars-forward " \t") (1+ pos)))))
(not (eolp))) ;; Show what follows the open in its line, if anything.
(buffer-substring pos ((save-excursion
(line-end-position))) (forward-char 1)
;; Otherwise show the previous nonblank line, (skip-chars-forward " \t")
;; if there is one. (not (eolp)))
((save-excursion (skip-chars-backward "\n \t") (not (bobp))) (setq regions (list (cons pos (line-end-position)))))
(concat ;; Otherwise show the previous nonblank line,
(buffer-substring (progn ;; if there is one.
(skip-chars-backward "\n \t") ((save-excursion (skip-chars-backward "\n \t") (not (bobp)))
(line-beginning-position)) (setq regions (list (cons (progn
(progn (end-of-line) (skip-chars-backward "\n \t")
(skip-chars-backward " \t") (line-beginning-position))
(point))) (progn (end-of-line)
;; Replace the newline and other whitespace with `...'. (skip-chars-backward " \t")
"..." (point)))
(buffer-substring pos (1+ pos)))) (cons pos (1+ pos)))))
;; There is nothing to show except the char itself. ;; There is nothing to show except the char itself.
(t (buffer-substring pos (1+ pos)))))) (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 (defvar blink-paren-function 'blink-matching-open
"Function called, if non-nil, whenever a close parenthesis is inserted. "Function called, if non-nil, whenever a close parenthesis is inserted.