Abstract timer interval as a variable

1 second is a bit too long, but old machines might want a longer
interval, I set it to 0.2 on my machine and CPU looks ok.
This commit is contained in:
Yuan Fu 2018-12-18 12:34:48 -05:00
parent c7a670d6b9
commit 112afa1137
No known key found for this signature in database
GPG Key ID: 1CF5ECABEC37A901
2 changed files with 8 additions and 2 deletions

View File

@ -18,6 +18,7 @@ Get the file, add to load path, and
** Variable
- =eldoc-box-max-pixel-width= & =eldoc-box-max-pixel-height= :: Set them according to the screen resolution of your machine.
- =eldoc-box-only-multi-line= :: Set this to non-nil and eldoc-box only display multi-line message in childframe. One line messages are left in minibuffer.
- =eldoc-box-cleanup-interval= :: After this amount of seconds will eldoc-box attempt to cleanup the childframe. E.g. if it is set to 1, the childframe is cleared 1 second after you moved the point to somewhere else (that doesn't have a doc to show).
** Use with eglot
As of writing this README, eglot doesn't have a public mode hook, use this hook:
#+BEGIN_SRC emacs-lisp

View File

@ -54,6 +54,11 @@
(defvar eldoc-box-only-multi-line nil
"If non-nil, only use childframe when there are more than one line.")
(defvar eldoc-box-cleanup-interval 1
"After this amount of seconds will eldoc-box attempt to cleanup the childframe.
E.g. if it is set to 1, the childframe is cleared 1 second after
you moved the point to somewhere else (that doesn't have a doc to show)")
(defvar eldoc-box-frame-parameters
'(
;; (left . -1)
@ -219,7 +224,7 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'."
;; setup another one to make sure the doc frame is cleared
;; once the condition above it met
(setq eldoc-box--cleanup-timer
(run-with-timer 1 nil #'eldoc-box--maybe-cleanup))))
(run-with-timer eldoc-box-cleanup-interval nil #'eldoc-box--maybe-cleanup))))
(defun eldoc-box--eldoc-message-function (str &rest args)
"Front-end for eldoc. Display STR in childframe and ARGS works like `message'."
@ -236,7 +241,7 @@ Checkout `lsp-ui-doc--make-frame', `lsp-ui-doc--move-frame'."
;; in `pre-command-hook', which means the timer is reset before every
;; command if `eldoc-box-hover-mode' is on and `eldoc-last-message' is not nil.
(setq eldoc-box--cleanup-timer
(run-with-timer 1 nil #'eldoc-box--maybe-cleanup))))
(run-with-timer eldoc-box-cleanup-interval nil #'eldoc-box--maybe-cleanup))))
t))
(provide 'eldoc-box)