[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/evil 8521dee34e: Wrap just show-paren-data-function in adv
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/evil 8521dee34e: Wrap just show-paren-data-function in advice |
Date: |
Tue, 10 Jan 2023 05:59:06 -0500 (EST) |
branch: elpa/evil
commit 8521dee34e0d3516019d38f2a537d82741179342
Author: Axel Forsman <axelsfor@gmail.com>
Commit: Axel Forsman <axelsfor@gmail.com>
Wrap just show-paren-data-function in advice
Instead of positioning the point and narrowing correctly for the
entirety of show-paren-function, just do it for the
show-paren-data-function call. This avoids duplicating the logic for
removing stale overlays, which had to support both the new and old names
of the once renamed show-paren--overlay variables.
Not narrowing during show-paren-function also fixes an issue with the
"mixed" show-paren-style, which uses pos-visible-in-window-p, see #1739.
Closes #1739
---
evil-integration.el | 50 +++++++++++++++++++-------------------------------
1 file changed, 19 insertions(+), 31 deletions(-)
diff --git a/evil-integration.el b/evil-integration.el
index 03fc3cfabc..f8ebfa7a1a 100644
--- a/evil-integration.el
+++ b/evil-integration.el
@@ -105,38 +105,26 @@
(defadvice show-paren-function (around evil disable)
"Match parentheses in Normal state."
- (if (if (memq 'not evil-highlight-closing-paren-at-point-states)
- (memq evil-state evil-highlight-closing-paren-at-point-states)
- (not (memq evil-state evil-highlight-closing-paren-at-point-states)))
+ (if (eq (not (memq 'not evil-highlight-closing-paren-at-point-states))
+ (not (memq evil-state evil-highlight-closing-paren-at-point-states)))
ad-do-it
- (let ((pos (point)) syntax narrow)
- (setq pos
- (catch 'end
- (dotimes (var (1+ (* 2 evil-show-paren-range)))
- (if (zerop (mod var 2))
- (setq pos (+ pos var))
- (setq pos (- pos var)))
- (setq syntax (syntax-class (syntax-after pos)))
- (cond
- ((eq syntax 4)
- (setq narrow pos)
- (throw 'end pos))
- ((eq syntax 5)
- (throw 'end (1+ pos)))))))
- (if pos
- (save-excursion
- (goto-char pos)
- (save-restriction
- (when narrow
- (narrow-to-region narrow (point-max)))
- ad-do-it))
- ;; prevent the preceding pair from being highlighted
- (dolist (ov '(show-paren--overlay
- show-paren--overlay-1
- show-paren-overlay
- show-paren-overlay-1))
- (let ((ov (and (boundp ov) (symbol-value ov))))
- (when (overlayp ov) (delete-overlay ov))))))))
+ (let* ((orig-spdf show-paren-data-function)
+ (show-paren-data-function
+ (lambda ()
+ (let ((pos (point)) narrow)
+ (setq
+ pos (cl-dotimes (i (1+ (* 2 evil-show-paren-range)))
+ (setq pos (+ pos (if (cl-evenp i) i (- i))))
+ (pcase (syntax-class (syntax-after pos))
+ (4 (setq narrow pos) (cl-return pos))
+ (5 (cl-return (1+ pos))))))
+ (when pos
+ (save-excursion
+ (goto-char pos)
+ (save-restriction
+ (when narrow (narrow-to-region narrow (point-max)))
+ (funcall orig-spdf))))))))
+ ad-do-it)))
;;; Undo tree
(eval-after-load 'undo-tree
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [nongnu] elpa/evil 8521dee34e: Wrap just show-paren-data-function in advice,
ELPA Syncer <=