From 374ce4e29f1b025feed77aa2cb7e90a67864760e Mon Sep 17 00:00:00 2001 From: ambihelical Date: Sat, 11 May 2019 11:41:52 -0700 Subject: [PATCH] Allow user to set idle time to wait before processing changes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * eglot.el (eglot-send-changes-idle-time): New defcustom. (eglot--after-change): Use it. Co-authored-by: João Távora Copyright-paperwork-exempt: yes GitHub-reference: fix https://github.com/joaotavora/eglot/issues/258 --- lisp/progmodes/eglot.el | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index 0a9da05b1c6..1dc57113984 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -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 @@ -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 -- 2.39.2