Add 'eldoc-box-help-at-point'

* eldoc-box.el (eldoc-box--help-at-point-last-point): New variable
(eldoc-box--help-at-point-cleanup): New function.
(eldoc-box-help-at-point): New command.
This commit is contained in:
Yuan Fu 2022-06-11 19:42:56 -07:00
parent 1ba418ba2b
commit 92100b2a2d
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442

View File

@ -178,6 +178,32 @@ Intended for internal use."
(delete-frame eldoc-box--frame) (delete-frame eldoc-box--frame)
(setq eldoc-box--frame nil))) (setq eldoc-box--frame nil)))
;;;;; Help at point
(defvar eldoc-box--help-at-point-last-point 0
"This point cache is used by clean up function.
If (point) != last point, cleanup frame.")
(defun eldoc-box--help-at-point-cleanup ()
"Try to clean up the childframe made by eldoc-box hack."
(if (or (eq (point) eldoc-box--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--help-at-point-cleanup)
(eldoc-box-quit-frame)
(kill-local-variable 'eldoc-display-functions)))
(defun eldoc-box-help-at-point ()
"Display documentation of the symbol at point."
(interactive)
(let ((eldoc-box-position-function
#'eldoc-box--default-at-point-position-function))
(eldoc-box--display
(with-current-buffer eldoc--doc-buffer
(buffer-string))))
(setq eldoc-box--help-at-point-last-point (point))
(run-with-timer 0.1 nil #'eldoc-box--help-at-point-cleanup))
;;;; Backstage ;;;; Backstage
;;;;; Variable ;;;;; Variable
(defvar eldoc-box--buffer " *eldoc-box*" (defvar eldoc-box--buffer " *eldoc-box*"