- face)
- ;;
- ;; Highlight the other end of the sexp, or unhighlight if none.
- (if (not (or pos mismatch))
- (progn
- ;; If not at a paren that has a match,
- ;; turn off any previous paren highlighting.
- (and show-paren-overlay (overlay-buffer show-paren-overlay)
- (delete-overlay show-paren-overlay))
- (and show-paren-overlay-1 (overlay-buffer show-paren-overlay-1)
- (delete-overlay show-paren-overlay-1)))
- ;;
- ;; Use the correct face.
- (if mismatch
- (progn
- (if show-paren-ring-bell-on-mismatch
- (beep))
- (setq face 'show-paren-mismatch))
- (setq face '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 (and (not show-paren-highlight-openparen) (= dir 1) (integerp pos))
- (when (and show-paren-overlay-1
- (overlay-buffer show-paren-overlay-1))
- (delete-overlay show-paren-overlay-1))
- (let ((from (nth 0 data))
- (to (nth 1 data)))
- (if show-paren-overlay-1
- (move-overlay show-paren-overlay-1 from to (current-buffer))
- (setq show-paren-overlay-1 (make-overlay from to nil t)))
- ;; 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 (integerp pos))
- (when show-paren-overlay (delete-overlay show-paren-overlay))
- (let ((to (if (or (eq show-paren-style 'expression)
- (and (eq show-paren-style 'mixed)
- (not (pos-visible-in-window-p pos))))
- (point)
- (nth 3 data)))
- (from (if (or (eq show-paren-style 'expression)
- (and (eq show-paren-style 'mixed)
- (not (pos-visible-in-window-p pos))))
- pos
- (nth 2 data))))
- (if show-paren-overlay
- (move-overlay show-paren-overlay from to (current-buffer))
- (setq show-paren-overlay (make-overlay from to nil t))))
- ;; Always set the overlay face, since it varies.
- (overlay-put show-paren-overlay 'priority show-paren-priority)
- (overlay-put show-paren-overlay 'face face))))
- ;; show-paren-mode is nil in this buffer.
- (and show-paren-overlay
- (delete-overlay show-paren-overlay))
- (and show-paren-overlay-1
- (delete-overlay show-paren-overlay-1))))
+ (face
+ (if mismatch
+ (progn
+ (if show-paren-ring-bell-on-mismatch
+ (beep))
+ 'show-paren-mismatch)
+ '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 (or (eq show-paren-style 'expression)
+ (and (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)))))
+ (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))))))