summaryrefslogtreecommitdiff
path: root/lisp/paren.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/paren.el')
-rw-r--r--lisp/paren.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/paren.el b/lisp/paren.el
index ce6aa9ae13b..7e7cf6c262a 100644
--- a/lisp/paren.el
+++ b/lisp/paren.el
@@ -88,6 +88,14 @@ is not highlighted, the cursor being regarded as adequate to mark
its position."
:type 'boolean)
+(defcustom show-paren-context-when-offscreen nil
+ "If non-nil, show context in the echo area when the openparen is offscreen.
+The context is usually the line that contains the openparen,
+except if the openparen is on its own line, in which case the
+context includes the previous nonblank line."
+ :type 'boolean
+ :version "29.1")
+
(defvar show-paren--idle-timer nil)
(defvar show-paren--overlay
(let ((ol (make-overlay (point) (point) nil t))) (delete-overlay ol) ol)
@@ -312,6 +320,19 @@ It is the default value of `show-paren-data-function'."
(current-buffer))
(move-overlay show-paren--overlay
there-beg there-end (current-buffer)))
+ ;; If `show-paren-open-line-when-offscreen' is t and point
+ ;; is at a close paren, show the line that contains the
+ ;; openparen in the echo area.
+ (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 ((open-paren-line-string
+ (blink-paren-open-paren-line-string openparen))
+ (message-log-max nil))
+ (minibuffer-message
+ "Matches %s"
+ (substring-no-properties open-paren-line-string)))))
;; Always set the overlay face, since it varies.
(overlay-put show-paren--overlay 'priority show-paren-priority)
(overlay-put show-paren--overlay 'face face))))))