Refactor eldoc-box-eglot-help-at-point

* eldoc-box.el (eldoc-box-eglot-help-at-point-last-point): Remove
variable.
(eldoc-box--eglot-help-at-point-cleanup): Remove function.
(eldoc-box-eglot-help-at-point): Use
'eldoc-box--help-at-point-cleanup' added in the last commit.
This commit is contained in:
Yuan Fu 2022-06-11 19:43:34 -07:00
parent 92100b2a2d
commit 39b44c99a0
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442

View File

@ -480,17 +480,6 @@ You can use \[keyboard-quit] to hide the doc."
(eval-and-compile (eval-and-compile
(require 'jsonrpc) (require 'jsonrpc)
(when (require 'eglot nil t) (when (require 'eglot nil t)
(defvar eldoc-box-eglot-help-at-point-last-point 0
"This point cache is used by clean up function.
If (point) != last point, cleanup frame.")
(defun eldoc-box--eglot-help-at-point-cleanup ()
"Try to clean up the childframe made by eldoc-box hack."
(if (or (eq (point) eldoc-box-eglot-help-at-point-last-point)
;; don't clean up when the user clicks childframe
(eq (selected-frame) eldoc-box--frame))
(run-with-timer 0.1 nil #'eldoc-box--eglot-help-at-point-cleanup)
(eldoc-box-quit-frame)))
(defvar eglot--managed-mode) (defvar eglot--managed-mode)
(declare-function eglot--dbind "eglot.el") (declare-function eglot--dbind "eglot.el")
@ -515,8 +504,8 @@ If (point) != last point, cleanup frame.")
(if hover-info (if hover-info
(eldoc-box--display hover-info) (eldoc-box--display hover-info)
(eglot--error "No hover info here")))) (eglot--error "No hover info here"))))
(setq eldoc-box-eglot-help-at-point-last-point (point)) (setq eldoc-box--help-at-point-last-point (point))
(run-with-timer 0.1 nil #'eldoc-box--eglot-help-at-point-cleanup))))) (run-with-timer 0.1 nil #'eldoc-box--help-at-point-cleanup)))))
;;;; Comany compatibility ;;;; Comany compatibility
;; ;;