From: Ingo Lohmar Date: Sun, 20 Oct 2019 10:21:37 +0000 (+0200) Subject: Only set eglot--cached-current-server by (more aggressive) caching X-Git-Tag: emacs-29.0.90~1616^2~524^2~4^2~280 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=19653f1e891d8a23afc46675579f9a3140fe582d;p=emacs.git Only set eglot--cached-current-server by (more aggressive) caching * eglot.el (eglot--current-server): Always set cache value. (eglot--maybe-activate-editing-mode): No need to set cached server. --- diff --git a/lisp/progmodes/eglot.el b/lisp/progmodes/eglot.el index e304ebd2b28..a0f57f41602 100644 --- a/lisp/progmodes/eglot.el +++ b/lisp/progmodes/eglot.el @@ -1277,13 +1277,15 @@ For example, to keep your Company customization use "A cached reference to the current EGLOT server.") (defun eglot--current-server () - "Find the current logical EGLOT server." + "Find and cache logical EGLOT server for current buffer." (or eglot--cached-current-server - (let* ((probe (or (project-current) - `(transient . ,default-directory)))) - (cl-find major-mode (gethash probe eglot--servers-by-project) - :key #'eglot--major-mode)))) + (setq eglot--cached-current-server + (cl-find major-mode + (gethash (or (project-current) + `(transient . ,default-directory)) + eglot--servers-by-project) + :key #'eglot--major-mode)))) (defun eglot--current-server-or-lose () "Return current logical EGLOT server connection or error." @@ -1305,12 +1307,10 @@ If it is activated, also signal textDocument/didOpen." (unless eglot--managed-mode ;; Called when `revert-buffer-in-progress-p' is t but ;; `revert-buffer-preserve-modes' is nil. - (let ((server (and buffer-file-name (eglot--current-server)))) - (when server - (setq eglot--unreported-diagnostics `(:just-opened . nil)) - (setq eglot--cached-current-server server) - (eglot--managed-mode) - (eglot--signal-textDocument/didOpen))))) + (when (and buffer-file-name (eglot--current-server)) + (setq eglot--unreported-diagnostics `(:just-opened . nil)) + (eglot--managed-mode) + (eglot--signal-textDocument/didOpen)))) (add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode) (add-hook 'after-change-major-mode-hook 'eglot--maybe-activate-editing-mode)