From 9d4eed2ff84ee142c5122e40eb4a5d7b0cbdea45 Mon Sep 17 00:00:00 2001 From: swiperthefox Date: Sat, 13 Dec 2014 00:05:14 -0500 Subject: [PATCH] Show matched tag in minibuffer if it is offscreen When the matched tag is offscreen, show the tag in minibuffer. If both the open tag and close tag are out of screen, show the opening tag in the minibuffer. --- hl-tags-mode.el | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/hl-tags-mode.el b/hl-tags-mode.el index a2a6ab3..9222240 100644 --- a/hl-tags-mode.el +++ b/hl-tags-mode.el @@ -102,12 +102,25 @@ boundaries of the current start and end tag , or nil." (hl-tags-context-sgml-mode))) (defun hl-tags-update () - (let ((ctx (hl-tags-context))) + (let* ((ctx (hl-tags-context)) + (start1 (caar ctx)) + (end1 (cdar ctx)) + (start2 (cadr ctx)) + (end2 (cddr ctx))) (if (null ctx) (hl-tags-hide) (hl-tags-show) - (move-overlay hl-tags-start-overlay (caar ctx) (cdar ctx)) - (move-overlay hl-tags-end-overlay (cadr ctx) (cddr ctx))))) + (move-overlay hl-tags-start-overlay start1 end1) + (move-overlay hl-tags-end-overlay start2 end2) + ; display the matched tag in the minibuffer if they are off screen. + (if (hl-tag-off-screen-p start1 end1) + (message "Open tag: %s" (buffer-substring start1 end1)) + (if (hl-tag-off-screen-p start2 end2) + (message "Close tag: %s" (buffer-substring start2 end2))))))) + +(defun hl-tag-off-screen-p (start end) + (or (> start (window-end)) + (< end (window-start)))) (defun hl-tags-show () (unless hl-tags-start-overlay