Add eldoc-box-at-point-position-function

* eldoc-box.el (eldoc-box-at-point-position-function): New variable.
(eldoc-box-help-at-point)
(eldoc-box-hover-at-point-mode): Replace hard-code with
eldoc-box-at-point-position-function.
This commit is contained in:
Yuan Fu 2023-07-28 22:40:50 -07:00
parent 2070e2fc16
commit f6ae0e7a7b
No known key found for this signature in database
GPG Key ID: 56E19BC57664A442

View File

@ -173,8 +173,17 @@ Its value should be a list: (left right top)"
(defvar eldoc-box-position-function #'eldoc-box--default-upper-corner-position-function
"Eldoc-box uses this function to set childframe's position.
This should be a function that returns a (X . Y) cons cell.
It will be passes with two arguments: WIDTH and HEIGHT of the childframe.")
The function is passed two arguments, WIDTH and HEIGHT of the
childframe, and should return a (X . Y) cons cell.")
(defvar eldoc-box-at-point-position-function #'eldoc-box--default-at-point-position-function
"Eldoc-box uses this function to set childframe's position.
This function is used in eldoc-box-help-at-point and in
eldoc-box-hover-at-point-mode.
The function is passed two arguments, WIDTH and HEIGHT of the
childframe, and should return a (X . Y) cons cell.")
(defcustom eldoc-box-fringe-use-same-bg t
"T means fringe's background color is set to as same as that of default."
@ -276,7 +285,7 @@ If point != last point, hide the childframe.")
(interactive)
(when (boundp 'eldoc--doc-buffer)
(let ((eldoc-box-position-function
#'eldoc-box--default-at-point-position-function))
eldoc-box-at-point-position-function))
(eldoc-box--display
(with-current-buffer eldoc--doc-buffer
(buffer-string))))
@ -630,7 +639,7 @@ You can use \\[keyboard-quit] to hide the doc."
(progn (when eldoc-box-hover-mode
(eldoc-box-hover-mode -1))
(setq-local eldoc-box-position-function
#'eldoc-box--default-at-point-position-function)
eldoc-box-at-point-position-function)
(setq-local eldoc-box-clear-with-C-g t)
(remove-hook 'pre-command-hook #'eldoc-pre-command-refresh-echo-area t)
(add-hook 'post-command-hook #'eldoc-box--follow-cursor t t)