From bafd61327abd7339e3fbaecaeb548f3181160f05 Mon Sep 17 00:00:00 2001 From: Samir Hafez Date: Wed, 18 Jul 2018 18:21:36 +0100 Subject: [PATCH] Added a content overlay This content overlay relates to anything between the matching pair. A new face `sp-show-pair-match-content-face` is available for customization. --- smartparens.el | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/smartparens.el b/smartparens.el index e190d05f..332a82a9 100644 --- a/smartparens.el +++ b/smartparens.el @@ -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) @@ -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))) @@ -9416,7 +9424,7 @@ 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))) @@ -9424,10 +9432,8 @@ has been created." (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 ()