Compare commits

...

3 Commits

2 changed files with 24 additions and 22 deletions

View File

@ -7,6 +7,9 @@ Forked from the excellent [eldoc-box](https://github.com/casouri/eldoc-box/) pac
<!-- [![MELPA](https://melpa.org/packages/mood-line-badge.svg)](https://melpa.org/#/eldoc-frame) -->
<!-- [![MELPA Stable](https://stable.melpa.org/packages/mood-line-badge.svg)](https://stable.melpa.org/#/eldoc-frame) -->
**NOTE**: This package is not yet considered to be in a "released" state. Breaking changes may occur without warning,
and it is not currently available on MELPA.
## Preview
![Preview Image](.repo-assets/preview.webp "Preview Image")

View File

@ -331,28 +331,27 @@ All functions are run with the eldoc child frame selected."
;; Frame geometry
;; ---------------------------------- ;;
(defun eldoc-frame--selected-window-side ()
"Return which side of the frame the selected window is on.
Return left if the selected window is on the left, or right if the selected
window is on the right. Return left if there is only one window in the frame."
(let* ((window-left (nth 0 (window-absolute-pixel-edges)))
(window-right (nth 2 (window-absolute-pixel-edges)))
(frame-left (nth 0 (frame-edges)))
(frame-right (nth 2 (frame-edges)))
(distance-left (- window-left frame-left))
(distance-right (- frame-right window-right)))
(if (<= distance-left distance-right) 'left 'right)))
(defun eldoc-frame--calc-frame-x-position (frame)
"Calculate the appropriate X position (offset) for FRAME."
(pcase-let ((`(,offset-l ,offset-r) eldoc-frame-offset))
(pcase (eldoc-frame--selected-window-side)
;; Selected window is on the left, so child frame should be on the right:
('left (- (frame-pixel-width (selected-frame))
(frame-pixel-width frame)
offset-r))
;; Selected window is on the right, so child frame should be on the left:
('right offset-l))))
"Calculate the appropriate X position (offset) for FRAME.
If the selected window is on the right side of the selected frame and is too
small to overlay FRAME over, or if `point' is too close to the right edge of the
selected frame, return an X coordinate that will place FRAME on the left side of
the selected frame. Otherwise, return an X coordinate that will place FRAME on
the right side of the selected frame."
(let ((offset-l (nth 0 eldoc-frame-offset))
(offset-r (nth 2 eldoc-frame-offset))
(window-left (nth 0 (window-absolute-pixel-edges)))
(min-containing-width (* (eval eldoc-frame-max-pixel-width) 2))
(cursor-x-position (or (car (window-absolute-pixel-position)) 0)))
(if (or (and (< (window-pixel-width) min-containing-width)
(> window-left (* (frame-pixel-width) .40)))
(> cursor-x-position (* (frame-pixel-width) .70)))
;; FRAME should be displayed on the left:
offset-l
;; FRAME should be displayed on the right:
(- (frame-pixel-width (selected-frame))
(frame-pixel-width frame)
offset-r))))
(defun eldoc-frame--update-frame-geometry (frame)
"Update size and position of FRAME."
@ -534,7 +533,7 @@ reused. Otherwise, a new frame is created by `eldoc-frame--create-child-frame'."
(when (timerp eldoc-frame--idle-timer)
(setq eldoc-frame--idle-timer (cancel-timer eldoc-frame--idle-timer)))
;; Remove window state change hooks
(remove-hook 'window-size-change-functions #'eldoc-frame--maybe-resize-frame)
(remove-hook 'window-state-change-hook #'eldoc-frame--maybe-resize-frame)
(remove-hook 'window-state-change-hook #'eldoc-frame--maybe-hide-frame)
;; Restore the original buffer-local value of `eldoc-display-functions'
(setq-local eldoc-display-functions