branch: elpa/highlight-parentheses commit a5eace239618a7a16aa4bdc6109f7b01d12ef692 Author: Tim Perkins <tpr...@gmail.com> Commit: Tim Perkins <tpr...@gmail.com>
Added option for highlighting adjacent parens. --- highlight-parentheses.el | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/highlight-parentheses.el b/highlight-parentheses.el index bdffd37..fcdb5ab 100644 --- a/highlight-parentheses.el +++ b/highlight-parentheses.el @@ -1,6 +1,7 @@ ;;; highlight-parentheses.el --- highlight surrounding parentheses ;; ;; Copyright (C) 2007, 2009, 2013 Nikolaj Schumacher +;; Copyright (C) 2018 Tim Perkins ;; ;; Author: Nikolaj Schumacher <bugs * nschum de> ;; Maintainer: Tassilo Horn <t...@gnu.org> @@ -69,6 +70,12 @@ The list starts with the inside parentheses and moves outwards." :set 'hl-paren-set :group 'highlight-parentheses) +(defcustom hl-paren-highlight-adjacent nil + "Highlight adjacent parentheses, just like show-paren-mode." + :type '(boolean) + :set 'hl-paren-set + :group 'highlight-parentheses) + (defface hl-paren-face nil "Face used for highlighting parentheses. Color attributes might be overriden by `hl-paren-colors' and @@ -98,17 +105,19 @@ This is used to prevent analyzing the same context over and over.") (unless (= (point) hl-paren-last-point) (setq hl-paren-last-point (point)) (let ((overlays hl-paren-overlays) - pos1 pos2 - (pos (point))) + pos1 pos2) (save-excursion - (condition-case err - (while (and (setq pos1 (cadr (syntax-ppss pos1))) - (cdr overlays)) - (move-overlay (pop overlays) pos1 (1+ pos1)) - (when (setq pos2 (scan-sexps pos1 1)) - (move-overlay (pop overlays) (1- pos2) pos2))) - (error nil)) - (goto-char pos)) + (ignore-errors + (when hl-paren-highlight-adjacent + (cond ((eq ?\) (preceding-char)) + (backward-char 1)) + ((eq ?\( (following-char)) + (forward-char 1)))) + (while (and (setq pos1 (cadr (syntax-ppss pos1))) + (cdr overlays)) + (move-overlay (pop overlays) pos1 (1+ pos1)) + (when (setq pos2 (scan-sexps pos1 1)) + (move-overlay (pop overlays) (1- pos2) pos2))))) (hl-paren-delete-overlays overlays)))) (defcustom hl-paren-delay 0.137