[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot 1a61522 08/16: Close #32: Cache buffer's managing
From: |
João Távora |
Subject: |
[elpa] externals/eglot 1a61522 08/16: Close #32: Cache buffer's managing server |
Date: |
Mon, 9 Jul 2018 17:27:13 -0400 (EDT) |
branch: externals/eglot
commit 1a615222b2cf46885aee275484e91647bc7c6c85
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Close #32: Cache buffer's managing server
* eglot.el (eglot--cached-current-server): New variable.
(eglot--managed-mode-onoff): Set it.
(eglot--current-server): Read it.
(eglot--maybe-activate-editing-mode): Add assertion.
---
eglot.el | 30 +++++++++++++++++++++++-------
1 file changed, 23 insertions(+), 7 deletions(-)
diff --git a/eglot.el b/eglot.el
index 88746a7..01658f9 100644
--- a/eglot.el
+++ b/eglot.el
@@ -708,23 +708,33 @@ If optional MARKERS, make markers."
(remove-function (local 'imenu-create-index-function) #'eglot-imenu)
(setq eglot--current-flymake-report-fn nil))))
+(defvar-local eglot--cached-current-server nil
+ "A cached reference to the current EGLOT server.
+Reset in `eglot--managed-mode-onoff'.")
+
(defun eglot--managed-mode-onoff (server arg)
"Proxy for function `eglot--managed-mode' with ARG and SERVER."
(eglot--managed-mode arg)
(let ((buf (current-buffer)))
- (if eglot--managed-mode
- (cl-pushnew buf (eglot--managed-buffers server))
- (setf (eglot--managed-buffers server)
- (delq buf (eglot--managed-buffers server))))))
+ (cond (eglot--managed-mode
+ (setq eglot--cached-current-server server)
+ (cl-pushnew buf (eglot--managed-buffers server)))
+ (t
+ (setq eglot--cached-current-server nil)
+ (setf (eglot--managed-buffers server)
+ (delq buf (eglot--managed-buffers server)))))))
(add-hook 'eglot--managed-mode-hook 'flymake-mode)
(add-hook 'eglot--managed-mode-hook 'eldoc-mode)
(defun eglot--current-server ()
"Find the current logical EGLOT server."
- (let* ((probe (or (project-current) `(transient . ,default-directory))))
- (cl-find major-mode (gethash probe eglot--servers-by-project)
- :key #'eglot--major-mode)))
+ (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))))
(defun eglot--current-server-or-lose ()
"Return current logical EGLOT server connection or error."
@@ -738,6 +748,12 @@ If optional MARKERS, make markers."
"Maybe activate mode function `eglot--managed-mode'.
If SERVER is supplied, do it only if BUFFER is managed by it. In
that case, also signal textDocument/didOpen."
+ (unless server
+ (when eglot--cached-current-server
+ (display-warning
+ :eglot "`eglot--cached-current-server' is non-nil, but it should be!\n\
+Please report this as a possible bug.")
+ (setq eglot--cached-current-server nil)))
;; Called even when revert-buffer-in-progress-p
(let* ((cur (and buffer-file-name (eglot--current-server)))
(server (or (and (null server) cur) (and server (eq server cur)
cur))))
- [elpa] externals/eglot updated (f385d9c -> 07b235f), João Távora, 2018/07/09
- [elpa] externals/eglot e8f0d89 02/16: * jsonrpc.el (jsonrpc-process-type): Actually return process-type., João Távora, 2018/07/09
- [elpa] externals/eglot 6239ca6 05/16: Close #30: Fix typo in the solargraph server program, João Távora, 2018/07/09
- [elpa] externals/eglot c94b028 04/16: Fix some rather silly bugs in some interactive specs, João Távora, 2018/07/09
- [elpa] externals/eglot a6fee46 09/16: Fix typo (#35), João Távora, 2018/07/09
- [elpa] externals/eglot 7467c15 11/16: Close #36: Inhibit auto-reconnect until connection is established, João Távora, 2018/07/09
- [elpa] externals/eglot a261a7b 10/16: Close #33: Bind default-directory when launching servers, João Távora, 2018/07/09
- [elpa] externals/eglot 543483a 13/16: Close #37: Unbreak completion when no possible annotation, João Távora, 2018/07/09
- [elpa] externals/eglot 1a61522 08/16: Close #32: Cache buffer's managing server,
João Távora <=
- [elpa] externals/eglot 37296ed 14/16: Format documentation in completion annotations, João Távora, 2018/07/09
- [elpa] externals/eglot 45c651e 06/16: Per #31: Unbreak basic imenu functionality, João Távora, 2018/07/09
- [elpa] externals/eglot a99e129 03/16: Adjust timeout strategy when running tests, João Távora, 2018/07/09
- [elpa] externals/eglot 017fbdc 07/16: Close #31: Unbreak Imenu for cquery servers (and probably more), João Távora, 2018/07/09
- [elpa] externals/eglot 8219088 12/16: Close #34: Handle outrageously large and buggy line numbers, João Távora, 2018/07/09
- [elpa] externals/eglot 55ee8e9 15/16: * eglot.el (eglot-completion-at-point): Fix broken indentation, João Távora, 2018/07/09
- [elpa] externals/eglot 4354710 01/16: Implement TCP autostart/autoconnect (and support Ruby's Solargraph), João Távora, 2018/07/09
- [elpa] externals/eglot 07b235f 16/16: jsonrpc.el is now a GNU ELPA depedency, João Távora, 2018/07/09