From 88b3b438f212481eb29778d4926dc2271f6b6752 Mon Sep 17 00:00:00 2001 From: Clemens Radermacher Date: Mon, 15 Feb 2021 13:47:11 +0100 Subject: [PATCH] Handle position argument --- quick-peek.el | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/quick-peek.el b/quick-peek.el index 9c6de30..60eed35 100644 --- a/quick-peek.el +++ b/quick-peek.el @@ -198,7 +198,7 @@ window." (let ((visible-lines (quick-peek--count-visible-lines-under (point)))) (max min-h (min max-h (- visible-lines 2)))))) -(defun quick-peek-update (ov &optional min-h max-h) +(defun quick-peek-update (ov &optional min-h max-h pos) "Redraw quick-peek overlay OV. MIN-H and MAX-H are bounds on the height of the window. If MAX-H @@ -209,7 +209,7 @@ Calling this method is only useful after directly setting the contents of a quick-peek overlay. Most programs should not need to do so (call `quick-peek-show' directly instead)." (save-excursion - (goto-char (overlay-start ov)) + (goto-char (overlay-get ov 'quick-peek-pos)) (setq min-h (or min-h 4) max-h (or max-h 16)) (let* ((contents (quick-peek-overlay-contents ov)) (offset (quick-peek--text-width (quick-peek--point-at-bovl) (point))) @@ -239,6 +239,7 @@ instead." (goto-char pos) (make-overlay (point-at-bol) (1+ (point-at-eol)))))) (overlay-put ov 'quick-peek t) + (overlay-put ov 'quick-peek-pos pos) (push ov quick-peek--overlays) ov))) @@ -249,15 +250,17 @@ is `none', let the inline window expand beyond the end of the selected Emacs window." (let ((ov (quick-peek-overlay-ensure-at pos))) (setf (quick-peek-overlay-contents ov) str) - (quick-peek-update ov min-h max-h))) + (quick-peek-update ov min-h max-h pos))) ;;;###autoload (defun quick-peek-show (str &optional pos min-h max-h) "Show STR in an inline window at POS. -MIN-H (default: 4) and MAX-H (default: 16) are bounds on the -height of the window. Setting MAX-H to `none' allows the inline -window to expand past the bottom of the current Emacs window." - (ignore (quick-peek--show-at (or pos (point)) str min-h max-h))) +POS (default: `point-at-bol') is the position in whichs column +the STR should be shown. MIN-H (default: 4) and MAX-H (default: +16) are bounds on the height of the window. Setting MAX-H to +`none' allows the inline window to expand past the bottom of the +current Emacs window." + (ignore (quick-peek--show-at (or pos (point-at-bol)) str min-h max-h))) (defun quick-peek--overlay-matches-pos (ov pos) "Check if OV is a quick-peek overlay covering POS."