Skip to content

Commit

Permalink
Added a content overlay
Browse files Browse the repository at this point in the history
This content overlay relates to anything between the matching pair.
A new face `sp-show-pair-match-content-face` is available for customization.
  • Loading branch information
Samir Hafez committed Jul 18, 2018
1 parent 34b5332 commit bafd613
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions smartparens.el
Original file line number Diff line number Diff line change
Expand Up @@ -9223,6 +9223,11 @@ the opening delimiter or before the closing delimiter."
"The face used to highlight pair overlays."
:group 'show-smartparens)

(defface sp-show-pair-match-content-face
'()
"`show-smartparens-mode' face used for a matching pair's content."
:group 'show-smartparens)

(defvar sp-show-pair-idle-timer nil)

(defvar sp-show-pair-overlays nil)
Expand Down Expand Up @@ -9355,11 +9360,14 @@ matching paren in the echo area if not visible on screen."
(when sp-show-pair-overlays
(sp-show--pair-delete-overlays))
(let* ((oleft (make-overlay start (+ start olen) nil t nil))
(omiddle (make-overlay (+ start olen) (- end clen) nil t nil))
(oright (make-overlay (- end clen) end nil t nil)))
(setq sp-show-pair-overlays (cons oleft oright))
(setq sp-show-pair-overlays (list oleft omiddle oright))
(overlay-put oleft 'face 'sp-show-pair-match-face)
(overlay-put omiddle 'face 'sp-show-pair-match-content-face)
(overlay-put oright 'face 'sp-show-pair-match-face)
(overlay-put oleft 'priority 1000)
(overlay-put omiddle 'priority 1000)
(overlay-put oright 'priority 1000)
(overlay-put oleft 'type 'show-pair)))

Expand Down Expand Up @@ -9416,18 +9424,16 @@ has been created."
(when sp-show-pair-overlays
(sp-show--pair-delete-overlays))
(let ((o (make-overlay start (+ start len) nil t nil)))
(setq sp-show-pair-overlays (cons o nil))
(setq sp-show-pair-overlays (list o))
(overlay-put o 'face 'sp-show-pair-mismatch-face)
(overlay-put o 'priority 1000)
(overlay-put o 'type 'show-pair)))

(defun sp-show--pair-delete-overlays ()
"Remove both show pair overlays."
(when sp-show-pair-overlays
(when (car sp-show-pair-overlays)
(delete-overlay (car sp-show-pair-overlays)))
(when (cdr sp-show-pair-overlays)
(delete-overlay (cdr sp-show-pair-overlays)))
(dolist (overlay sp-show-pair-overlays)
(delete-overlay overlay))
(setq sp-show-pair-overlays nil)))

(defun sp-show--pair-delete-enc-overlays ()
Expand Down

0 comments on commit bafd613

Please sign in to comment.