Skip to content

Commit

Permalink
Allow user to set idle time to wait before processing changes
Browse files Browse the repository at this point in the history
* eglot.el (eglot-send-changes-idle-time): New defcustom.
(eglot--after-change): Use it.

Co-authored-by: João Távora <[email protected]>
Copyright-paperwork-exempt: yes
GitHub-reference: fix joaotavora/eglot#258
  • Loading branch information
ambihelical and joaotavora committed Oct 5, 2019
1 parent 1c8d062 commit 374ce4e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lisp/progmodes/eglot.el
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,10 @@ as 0, i.e. don't block at all."
"If non-nil, shut down server after killing last managed buffer."
:type 'boolean)

(defcustom eglot-send-changes-idle-time 0.5
"Don't tell server of changes before Emacs's been idle for this many seconds."
:type 'number)

(defcustom eglot-events-buffer-size 2000000
"Control the size of the Eglot events buffer.
If a number, don't let the buffer grow larger than that many
Expand Down Expand Up @@ -1591,10 +1595,11 @@ Records BEG, END and PRE-CHANGE-LENGTH locally."
(let ((buf (current-buffer)))
(setq eglot--change-idle-timer
(run-with-idle-timer
0.5 nil (lambda () (eglot--with-live-buffer buf
(when eglot--managed-mode
(eglot--signal-textDocument/didChange)
(setq eglot--change-idle-timer nil))))))))
eglot-send-changes-idle-time
nil (lambda () (eglot--with-live-buffer buf
(when eglot--managed-mode
(eglot--signal-textDocument/didChange)
(setq eglot--change-idle-timer nil))))))))

;; HACK! Launching a deferred sync request with outstanding changes is a
;; bad idea, since that might lead to the request never having a
Expand Down

0 comments on commit 374ce4e

Please sign in to comment.