Skip to content

Commit

Permalink
Merge pull request #910 from SamirHafez/content-overlay
Browse files Browse the repository at this point in the history
Ability to highlight a pair's content
  • Loading branch information
Fuco1 authored Jul 25, 2018
2 parents 34b5332 + bafd613 commit 7b36067
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 7b36067

Please sign in to comment.