Function: blink-paren-open-paren-line-string
blink-paren-open-paren-line-string is a byte-compiled function defined
in simple.el.gz.
Signature
(blink-paren-open-paren-line-string POS)
Documentation
Return the line string that contains the openparen at POS.
Remove the line string's properties but give the openparen a distinct
face if blink-matching-paren-highlight-offscreen is non-nil.
Source Code
;; Defined in /usr/src/emacs/lisp/simple.el.gz
(defun blink-paren-open-paren-line-string (pos)
"Return the line string that contains the openparen at POS.
Remove the line string's properties but give the openparen a distinct
face if `blink-matching-paren-highlight-offscreen' is non-nil."
(save-excursion
(goto-char 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
openparen-idx)
(cond
;; Show what precedes the open in its line, if anything.
((save-excursion (skip-chars-backward " \t") (not (bolp)))
(let ((bol (line-beginning-position)))
(setq regions (list (cons bol (1+ pos)))
openparen-idx (- pos bol))))
;; 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)))
openparen-idx 0))
;; Otherwise show the previous nonblank line,
;; if there is one.
((save-excursion (skip-chars-backward "\n \t") (not (bobp)))
(setq regions (list (cons
(let (bol)
(skip-chars-backward "\n \t")
(setq bol (line-beginning-position)
openparen-idx (- bol))
bol)
(let (eol)
(end-of-line)
(skip-chars-backward " \t")
(setq eol (point)
openparen-idx (+ openparen-idx
eol
;; (length "...")
3))
eol))
(cons pos (1+ pos)))))
;; There is nothing to show except the char itself.
(t (setq regions (list (cons pos (1+ pos)))
openparen-idx 0)))
;; Ensure we've font-locked the context region.
(font-lock-ensure (caar regions) (cdar (last regions)))
(let ((line-string
(mapconcat
(lambda (region)
(buffer-substring (car region) (cdr region)))
regions
"..."))
(openparen-next-char-idx (1+ openparen-idx)))
(setq line-string (substring-no-properties line-string))
(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 matched-offscreen-openparen
'face 'blink-matching-paren-offscreen)
matched-offscreen-openparen))
(substring line-string
openparen-next-char-idx))))))