aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorFelipe Ochoa2017-08-18 12:05:12 +0300
committerEli Zaretskii2017-08-18 12:05:12 +0300
commitfb1a489757eb9237afbd2e39e453e4a5e06c9d86 (patch)
treee7586e197cdfbc145710fcbc07da682199a5c091 /lisp
parent99b3250d04288260e3a6db864cda910d8093bee1 (diff)
downloademacs-fb1a489757eb9237afbd2e39e453e4a5e06c9d86.tar.gz
emacs-fb1a489757eb9237afbd2e39e453e4a5e06c9d86.zip
A new face for show-paren in expression mode
* lisp/faces.el (show-paren-match-expression): Define the new face. * lisp/paren.el (show-paren-function): Apply the different face when in expression mode. (Bug#28047) Copyright-paperwork-exempt: yes
Diffstat (limited to 'lisp')
-rw-r--r--lisp/faces.el7
-rw-r--r--lisp/paren.el26
2 files changed, 22 insertions, 11 deletions
diff --git a/lisp/faces.el b/lisp/faces.el
index 01d94d7aae0..d9c90fda6be 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -2854,6 +2854,13 @@ It is used for characters of no fonts too."
2854 "Face used for a matching paren." 2854 "Face used for a matching paren."
2855 :group 'paren-showing-faces) 2855 :group 'paren-showing-faces)
2856 2856
2857(defface show-paren-match-expression
2858 '((t :inherit show-paren-match))
2859 "Face used for a matching paren when highlighting the whole expression.
2860This face is used by `show-paren-mode'."
2861 :group 'paren-showing-faces
2862 :version "26.1")
2863
2857(defface show-paren-mismatch 2864(defface show-paren-mismatch
2858 '((((class color)) (:foreground "white" :background "purple")) 2865 '((((class color)) (:foreground "white" :background "purple"))
2859 (t (:inverse-video t))) 2866 (t (:inverse-video t)))
diff --git a/lisp/paren.el b/lisp/paren.el
index a4d9200c42f..5ccfa5faa95 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -247,13 +247,21 @@ It is the default value of `show-paren-data-function'."
247 (there-beg (nth 2 data)) 247 (there-beg (nth 2 data))
248 (there-end (nth 3 data)) 248 (there-end (nth 3 data))
249 (mismatch (nth 4 data)) 249 (mismatch (nth 4 data))
250 (highlight-expression
251 (or (eq show-paren-style 'expression)
252 (and there-beg
253 (eq show-paren-style 'mixed)
254 (let ((closest (if (< there-beg here-beg)
255 (1- there-end) (1+ there-beg))))
256 (not (pos-visible-in-window-p closest))))))
250 (face 257 (face
251 (if mismatch 258 (cond
252 (progn 259 (mismatch
253 (if show-paren-ring-bell-on-mismatch 260 (if show-paren-ring-bell-on-mismatch
254 (beep)) 261 (beep))
255 'show-paren-mismatch) 262 'show-paren-mismatch)
256 'show-paren-match))) 263 (highlight-expression 'show-paren-match-expression)
264 (t 'show-paren-match))))
257 ;; 265 ;;
258 ;; If matching backwards, highlight the closeparen 266 ;; If matching backwards, highlight the closeparen
259 ;; before point as well as its matching open. 267 ;; before point as well as its matching open.
@@ -276,11 +284,7 @@ It is the default value of `show-paren-data-function'."
276 ;; If it's an unmatched paren, turn off any such highlighting. 284 ;; If it's an unmatched paren, turn off any such highlighting.
277 (if (not there-beg) 285 (if (not there-beg)
278 (delete-overlay show-paren--overlay) 286 (delete-overlay show-paren--overlay)
279 (if (or (eq show-paren-style 'expression) 287 (if highlight-expression
280 (and (eq show-paren-style 'mixed)
281 (let ((closest (if (< there-beg here-beg)
282 (1- there-end) (1+ there-beg))))
283 (not (pos-visible-in-window-p closest)))))
284 (move-overlay show-paren--overlay 288 (move-overlay show-paren--overlay
285 (if (< there-beg here-beg) here-end here-beg) 289 (if (< there-beg here-beg) here-end here-beg)
286 (if (< there-beg here-beg) there-beg there-end) 290 (if (< there-beg here-beg) there-beg there-end)