Skip to content

Commit

Permalink
Handle position argument
Browse files Browse the repository at this point in the history
  • Loading branch information
clemera committed Feb 15, 2021
1 parent 03a2760 commit 88b3b43
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions quick-peek.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)))
Expand Down Expand Up @@ -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)))

Expand All @@ -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."
Expand Down

0 comments on commit 88b3b43

Please sign in to comment.