Function: show-paren-function
show-paren-function is a byte-compiled function defined in
paren.el.gz.
Signature
(show-paren-function)
Documentation
Highlight the parentheses until the next input arrives.
Source Code
;; Defined in /usr/src/emacs/lisp/paren.el.gz
(defun show-paren-function ()
"Highlight the parentheses until the next input arrives."
(let ((data (and show-paren-mode (funcall show-paren-data-function))))
(if (not data)
(progn
;; If show-paren-mode is nil in this buffer or if not at a paren that
;; has a match, turn off any previous paren highlighting.
(delete-overlay show-paren--overlay)
(delete-overlay show-paren--overlay-1))
;; Found something to highlight.
(let* ((here-beg (nth 0 data))
(here-end (nth 1 data))
(there-beg (nth 2 data))
(there-end (nth 3 data))
(mismatch (nth 4 data))
(highlight-expression
(or (eq show-paren-style 'expression)
(and there-beg
(eq show-paren-style 'mixed)
(let ((closest (if (< there-beg here-beg)
(1- there-end) (1+ there-beg))))
(not (pos-visible-in-window-p closest))))))
(face
(cond
(mismatch
(if show-paren-ring-bell-on-mismatch
(beep))
'show-paren-mismatch)
(highlight-expression 'show-paren-match-expression)
(t 'show-paren-match))))
;;
;; If matching backwards, highlight the closeparen
;; before point as well as its matching open.
;; If matching forward, and the openparen is unbalanced,
;; highlight the paren at point to indicate misbalance.
;; Otherwise, turn off any such highlighting.
(if (or (not here-beg)
(and (not show-paren-highlight-openparen)
(> here-end (point))
(<= here-beg (point))
(integerp there-beg)))
(delete-overlay show-paren--overlay-1)
(move-overlay show-paren--overlay-1
here-beg here-end (current-buffer))
;; Always set the overlay face, since it varies.
(overlay-put show-paren--overlay-1 'priority show-paren-priority)
(overlay-put show-paren--overlay-1 'face face))
;;
;; Turn on highlighting for the matching paren, if found.
;; If it's an unmatched paren, turn off any such highlighting.
(if (not there-beg)
(delete-overlay show-paren--overlay)
(if highlight-expression
(move-overlay show-paren--overlay
(if (< there-beg here-beg) here-end here-beg)
(if (< there-beg here-beg) there-beg there-end)
(current-buffer))
(move-overlay show-paren--overlay
there-beg there-end (current-buffer)))
;; Always set the overlay face, since it varies.
(overlay-put show-paren--overlay 'priority show-paren-priority)
(overlay-put show-paren--overlay 'face face))))))