Compare commits

..

No commits in common. "7b0477697b85278c6981d82dcde42f02a740d3be" and "fb8e012d60078e2c519ffffeb93d9bb0fcea297d" have entirely different histories.

2 changed files with 22 additions and 24 deletions

View File

@ -7,9 +7,6 @@ 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](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) --> <!-- [![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
![Preview Image](.repo-assets/preview.webp "Preview Image") ![Preview Image](.repo-assets/preview.webp "Preview Image")

View File

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