>From a1d30d4b2941e2fd95f0c13c2bd789a6143e6b5e Mon Sep 17 00:00:00 2001 From: felipe Date: Fri, 11 Aug 2017 15:32:16 +0200 Subject: [PATCH] Use different faces for show-paren expression and parenthesis Use the show-paren-match-expression when to highlight expressions inside matching parentheses. * lisp/faces.el (show-paren-match-expression): Define the new face * lisp/paren.el (show-paren-function): Apply the different face --- lisp/faces.el | 5 +++++ lisp/paren.el | 26 +++++++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/lisp/faces.el b/lisp/faces.el index 5ed11d1..b96937a 100644 --- a/lisp/faces.el +++ b/lisp/faces.el @@ -2849,6 +2849,11 @@ It is used for characters of no fonts too." "Face used for a matching paren." :group 'paren-showing-faces) +(defface show-paren-match-expression + '((t :inherit show-paren-match)) + "Face used for a matching paren when highlighting the whole expression." + :group 'paren-showing-faces) + (defface show-paren-mismatch '((((class color)) (:foreground "white" :background "purple")) (t (:inverse-video t))) diff --git a/lisp/paren.el b/lisp/paren.el index a4d9200..5ccfa5f 100644 --- a/lisp/paren.el +++ b/lisp/paren.el @@ -247,13 +247,21 @@ It is the default value of `show-paren-data-function'." (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 - (if mismatch - (progn - (if show-paren-ring-bell-on-mismatch - (beep)) - 'show-paren-mismatch) - 'show-paren-match))) + (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. @@ -276,11 +284,7 @@ It is the default value of `show-paren-data-function'." ;; 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))))) + (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) -- 2.7.4