summaryrefslogtreecommitdiff
path: root/lisp/paren.el
diff options
context:
space:
mode:
authorTassilo Horn <tsdh@gnu.org>2022-02-09 15:14:18 +0100
committerTassilo Horn <tsdh@gnu.org>2022-02-09 15:15:32 +0100
commitbb69361cbeec0715c4786ab0864b6ab8b0a43a69 (patch)
tree6cc1f4b53be0a3470cd019a562d7cf4da9cc570b /lisp/paren.el
parent2386aa8a5d1b8b3f38361ee2d5228f739dfe2c3a (diff)
downloademacs-bb69361cbeec0715c4786ab0864b6ab8b0a43a69.tar.gz
emacs-bb69361cbeec0715c4786ab0864b6ab8b0a43a69.tar.bz2
emacs-bb69361cbeec0715c4786ab0864b6ab8b0a43a69.zip
show-paren: Don't show context again after C-g-ing it away.
* lisp/paren.el (show-paren--last-pos): New variable. (show-paren-function): Don't show context again after C-g-ing it away.
Diffstat (limited to 'lisp/paren.el')
-rw-r--r--lisp/paren.el38
1 files changed, 23 insertions, 15 deletions
diff --git a/lisp/paren.el b/lisp/paren.el
index 8d45987e90c..4cef9756bc9 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -398,6 +398,12 @@ It is the default value of `show-paren-data-function'."
(add-hook 'post-command-hook #'show-paren--delete-context-overlay
nil 'local))
+;; The last position of point for which `show-paren-function' was
+;; called. We track it in order to C-g away a context overlay or
+;; child-frame without having it pop up again after
+;; `show-paren-delay'.
+(defvar-local show-paren--last-pos nil)
+
(defun show-paren-function ()
"Highlight the parentheses until the next input arrives."
(let ((data (and show-paren-mode (funcall show-paren-data-function))))
@@ -462,21 +468,23 @@ It is the default value of `show-paren-data-function'."
;; point is at a closing paren, show the context around the
;; opening paren.
(let ((openparen (min here-beg there-beg)))
- (if (and show-paren-context-when-offscreen
- (< there-beg here-beg)
- (not (pos-visible-in-window-p openparen)))
- (let ((context (blink-paren-open-paren-line-string
- openparen))
- (message-log-max nil))
- (cond
- ((and
- (eq show-paren-context-when-offscreen 'child-frame)
- (display-graphic-p))
- (show-paren--show-context-in-child-frame context))
- ((eq show-paren-context-when-offscreen 'overlay)
- (show-paren--show-context-in-overlay context))
- (show-paren-context-when-offscreen
- (minibuffer-message "Matches %s" context))))))
+ (when (and show-paren-context-when-offscreen
+ (not (eql show-paren--last-pos (point)))
+ (< there-beg here-beg)
+ (not (pos-visible-in-window-p openparen)))
+ (let ((context (blink-paren-open-paren-line-string
+ openparen))
+ (message-log-max nil))
+ (cond
+ ((and
+ (eq show-paren-context-when-offscreen 'child-frame)
+ (display-graphic-p))
+ (show-paren--show-context-in-child-frame context))
+ ((eq show-paren-context-when-offscreen 'overlay)
+ (show-paren--show-context-in-overlay context))
+ (show-paren-context-when-offscreen
+ (minibuffer-message "Matches %s" context))))))
+ (setq show-paren--last-pos (point))
;; Always set the overlay face, since it varies.
(overlay-put show-paren--overlay 'priority show-paren-priority)
(overlay-put show-paren--overlay 'face face))))))