Fix slowness of the 'follow-cursor' feature
* eldoc-box.el (eldoc-box--inhibit-childframe-timer): Remove variable. (eldoc-box--inhibit-childframe-for): Refactor to use 'run-with-idle-timer' instead of 'run-with-timer' (eldoc-box--follow-cursor): Don't do anything if the timer is set
This commit is contained in:
parent
39b44c99a0
commit
cee5266af5
17
eldoc-box.el
17
eldoc-box.el
@ -317,29 +317,24 @@ FRAME is the childframe, WINDOW is the primary window."
|
|||||||
;; move position
|
;; move position
|
||||||
(set-frame-position frame (car pos) (cdr pos))))
|
(set-frame-position frame (car pos) (cdr pos))))
|
||||||
|
|
||||||
(defvar eldoc-box--inhibit-childframe-timer nil
|
|
||||||
"When this timer is on, inhibit childframe display.
|
|
||||||
Intended for follow-cursor to disable display when moving cursor.")
|
|
||||||
|
|
||||||
(defun eldoc-box--inhibit-childframe-for (sec)
|
(defun eldoc-box--inhibit-childframe-for (sec)
|
||||||
"Inhibit display of childframe for SEC seconds."
|
"Inhibit display of childframe for SEC seconds after Emacs is idle again."
|
||||||
(when eldoc-box--inhibit-childframe-timer
|
(unless eldoc-box--inhibit-childframe
|
||||||
(cancel-timer eldoc-box--inhibit-childframe-timer))
|
(setq eldoc-box--inhibit-childframe t)
|
||||||
(eldoc-box-quit-frame)
|
(eldoc-box-quit-frame)
|
||||||
(setq eldoc-box--inhibit-childframe t
|
(run-with-idle-timer sec nil
|
||||||
eldoc-box--inhibit-childframe-timer
|
|
||||||
(run-with-timer sec nil
|
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(setq eldoc-box--inhibit-childframe nil)))))
|
(setq eldoc-box--inhibit-childframe nil)))))
|
||||||
|
|
||||||
(defun eldoc-box--follow-cursor ()
|
(defun eldoc-box--follow-cursor ()
|
||||||
"Make childframe follow cursor in at-point mode."
|
"Make childframe follow cursor in at-point mode."
|
||||||
|
(unless eldoc-box--inhibit-childframe
|
||||||
(if (member this-command eldoc-box-self-insert-command-list)
|
(if (member this-command eldoc-box-self-insert-command-list)
|
||||||
(progn (when (frame-live-p eldoc-box--frame)
|
(progn (when (frame-live-p eldoc-box--frame)
|
||||||
(eldoc-box--update-childframe-geometry
|
(eldoc-box--update-childframe-geometry
|
||||||
eldoc-box--frame (frame-selected-window eldoc-box--frame))))
|
eldoc-box--frame (frame-selected-window eldoc-box--frame))))
|
||||||
;; if not typing, inhibit display
|
;; if not typing, inhibit display
|
||||||
(eldoc-box--inhibit-childframe-for 0.2)))
|
(eldoc-box--inhibit-childframe-for 0.5))))
|
||||||
|
|
||||||
(defun eldoc-box--get-frame (buffer)
|
(defun eldoc-box--get-frame (buffer)
|
||||||
"Return a childframe displaying BUFFER.
|
"Return a childframe displaying BUFFER.
|
||||||
|
Loading…
Reference in New Issue
Block a user