mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 18:40:39 -08:00
Allow showing show-paren context in an overlay
* lisp/paren.el (show-paren-context-when-offscreen): Add new possibility `overlay'. (show-paren--context-overlay): New defvar. (show-paren--delete-context-overlay): New function. (show-paren--show-context-in-overlay): New function. (show-paren-function): Handle the new `overlay' case. * lisp/emacs-lisp/eldoc.el (eldoc-display-message-no-interference-p): There's no interference if `show-paren-context-when-offscreen' is overlay or child-frame.
This commit is contained in:
parent
f7d16d93fd
commit
2755e6bba0
2 changed files with 47 additions and 10 deletions
|
|
@ -387,6 +387,10 @@ Also store it in `eldoc-last-message' and return that value."
|
||||||
;; conflicts with eldoc.
|
;; conflicts with eldoc.
|
||||||
(and (boundp 'show-paren-context-when-offscreen)
|
(and (boundp 'show-paren-context-when-offscreen)
|
||||||
show-paren-context-when-offscreen
|
show-paren-context-when-offscreen
|
||||||
|
;; There's no conflict with the child-frame and
|
||||||
|
;; overlay versions.
|
||||||
|
(not (memq show-paren-context-when-offscreen
|
||||||
|
'(child-frame overlay)))
|
||||||
(not (pos-visible-in-window-p
|
(not (pos-visible-in-window-p
|
||||||
(overlay-end show-paren--overlay)))))))
|
(overlay-end show-paren--overlay)))))))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -96,14 +96,18 @@ context includes the previous nonblank line.
|
||||||
|
|
||||||
By default, the context is shown in the echo area.
|
By default, the context is shown in the echo area.
|
||||||
|
|
||||||
|
If set to the symbol `overlay', the context is shown in an
|
||||||
|
overlay at the top-left of the window.
|
||||||
|
|
||||||
If set to the symbol `child-frame', the context is shown in a
|
If set to the symbol `child-frame', the context is shown in a
|
||||||
child frame at the top left of the window. You might want to
|
child frame at the top-left of the window. You might want to
|
||||||
customize the `child-frame-border' face (especially the
|
customize the `child-frame-border' face (especially the
|
||||||
background color) to give the child frame a distinguished border.
|
background color) to give the child frame a distinguished border.
|
||||||
On non-graphical frames, the context is shown in the echo area."
|
On non-graphical frames, the context is shown in the echo area."
|
||||||
:type '(choice (const :tag "Off" nil)
|
:type '(choice (const :tag "Off" nil)
|
||||||
(const :tag "In echo area" t)
|
(const :tag "In echo area" t)
|
||||||
(const :tag "Child frame" child-frame))
|
(const :tag "In overlay" overlay)
|
||||||
|
(const :tag "In child-frame" child-frame))
|
||||||
:version "29.1")
|
:version "29.1")
|
||||||
|
|
||||||
(defvar show-paren--idle-timer nil)
|
(defvar show-paren--idle-timer nil)
|
||||||
|
|
@ -368,6 +372,32 @@ It is the default value of `show-paren-data-function'."
|
||||||
(add-hook 'post-command-hook
|
(add-hook 'post-command-hook
|
||||||
#'show-paren--delete-context-child-frame))))
|
#'show-paren--delete-context-child-frame))))
|
||||||
|
|
||||||
|
(defvar-local show-paren--context-overlay nil)
|
||||||
|
|
||||||
|
(defun show-paren--delete-context-overlay ()
|
||||||
|
(when show-paren--context-overlay
|
||||||
|
(delete-overlay show-paren--context-overlay)
|
||||||
|
(setq show-paren--context-overlay nil))
|
||||||
|
(remove-hook 'post-command-hook #'show-paren--delete-overlays
|
||||||
|
'local))
|
||||||
|
|
||||||
|
(defun show-paren--show-context-in-overlay (text)
|
||||||
|
"Show TEXT in an overlay at the top-left of the current window."
|
||||||
|
(setq text (replace-regexp-in-string "\n" " " text))
|
||||||
|
(show-paren--delete-context-overlay)
|
||||||
|
(let* ((beg (window-start))
|
||||||
|
(end (save-excursion
|
||||||
|
(goto-char beg)
|
||||||
|
(line-end-position))))
|
||||||
|
(setq show-paren--context-overlay (make-overlay beg end)))
|
||||||
|
(overlay-put show-paren--context-overlay 'display text)
|
||||||
|
(overlay-put show-paren--context-overlay
|
||||||
|
'face `(:box
|
||||||
|
( :line-width (1 . -1)
|
||||||
|
:color ,(face-attribute 'shadow :foreground))))
|
||||||
|
(add-hook 'post-command-hook #'show-paren--delete-context-overlay
|
||||||
|
nil 'local))
|
||||||
|
|
||||||
(defun show-paren-function ()
|
(defun show-paren-function ()
|
||||||
"Highlight the parentheses until the next input arrives."
|
"Highlight the parentheses until the next input arrives."
|
||||||
(let ((data (and show-paren-mode (funcall show-paren-data-function))))
|
(let ((data (and show-paren-mode (funcall show-paren-data-function))))
|
||||||
|
|
@ -435,15 +465,18 @@ It is the default value of `show-paren-data-function'."
|
||||||
(if (and show-paren-context-when-offscreen
|
(if (and show-paren-context-when-offscreen
|
||||||
(< there-beg here-beg)
|
(< there-beg here-beg)
|
||||||
(not (pos-visible-in-window-p openparen)))
|
(not (pos-visible-in-window-p openparen)))
|
||||||
(let ((open-paren-line-string
|
(let ((context (blink-paren-open-paren-line-string
|
||||||
(blink-paren-open-paren-line-string openparen))
|
openparen))
|
||||||
(message-log-max nil))
|
(message-log-max nil))
|
||||||
(if (and (eq show-paren-context-when-offscreen
|
(cond
|
||||||
'child-frame)
|
((and
|
||||||
(display-graphic-p))
|
(eq show-paren-context-when-offscreen 'child-frame)
|
||||||
(show-paren--show-context-in-child-frame
|
(display-graphic-p))
|
||||||
open-paren-line-string)
|
(show-paren--show-context-in-child-frame context))
|
||||||
(minibuffer-message "Matches %s" open-paren-line-string)))))
|
((eq show-paren-context-when-offscreen 'overlay)
|
||||||
|
(show-paren--show-context-in-overlay context))
|
||||||
|
(show-paren-context-when-offscreen
|
||||||
|
(minibuffer-message "Matches %s" context))))))
|
||||||
;; Always set the overlay face, since it varies.
|
;; Always set the overlay face, since it varies.
|
||||||
(overlay-put show-paren--overlay 'priority show-paren-priority)
|
(overlay-put show-paren--overlay 'priority show-paren-priority)
|
||||||
(overlay-put show-paren--overlay 'face face))))))
|
(overlay-put show-paren--overlay 'face face))))))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue