[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa 0e95167 042/139: Watch for files opened under umbr
From: |
João Távora |
Subject: |
[elpa] externals/elpa 0e95167 042/139: Watch for files opened under umbrella of existing process |
Date: |
Mon, 14 May 2018 09:53:31 -0400 (EDT) |
branch: externals/elpa
commit 0e951677e486a48a1ec583382d77e04b8a457d37
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Watch for files opened under umbrella of existing process
* eglot.el (eglot--connect): Call success-fn with a proc.
(eglot-reconnect): Adapt to new eglot--connect.
(eglot-new-process): Call eglot--maybe-activate-editing-mode
(eglot--maybe-activate-editing-mode): New function.
(find-file-hook): Add it here.
---
eglot.el | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
diff --git a/eglot.el b/eglot.el
index 10af6c5..f4ac858 100644
--- a/eglot.el
+++ b/eglot.el
@@ -190,7 +190,7 @@ SUCCESS-FN with no args if all goes well."
(lambda (&key capabilities)
(setf (eglot--capabilities proc) capabilities)
(setf (eglot--status proc) nil)
- (when success-fn (funcall success-fn)))))))))
+ (when success-fn (funcall success-fn proc)))))))))
(defun eglot-reconnect (process &optional interactive)
"Reconnect to PROCESS.
@@ -203,8 +203,8 @@ INTERACTIVE is t if called interactively."
(eglot--major-mode process)
(eglot--short-name process)
(eglot--bootstrap-fn process)
- (lambda ()
- (eglot--message "Reconnected"))))
+ (lambda (_proc)
+ (eglot--message "Reconnected!"))))
(defvar eglot--command-history nil
"History of COMMAND arguments to `eglot-new-process'.")
@@ -273,21 +273,15 @@ INTERACTIVE is t if called interactively."
(eglot-make-local-process
name
command))
- (lambda ()
- (eglot--message "Connected. Managing `%s' buffers in project %s."
- managed-major-mode short-name)
+ (lambda (proc)
+ (eglot--message "Connected! Process `%s' now managing `%s'\
+buffers in project %s."
+ proc
+ managed-major-mode
+ short-name)
(dolist (buffer (buffer-list))
(with-current-buffer buffer
- (when(and buffer-file-name
- (cl-some
- (lambda (root)
- (string-prefix-p
- (expand-file-name root)
- (expand-file-name buffer-file-name)))
- (project-roots project)))
- (unless eglot-editing-mode
- (eglot-editing-mode 1))
- (eglot--signalDidOpen)))))))))))
+ (eglot--maybe-activate-editing-mode proc))))))))))
(defun eglot--process-sentinel (process change)
"Called with PROCESS undergoes CHANGE."
@@ -706,7 +700,7 @@ running. INTERACTIVE is t if called interactively."
-;;; Mode line
+;;; Minor modes and mode-line
;;;
(defface eglot-mode-line
'((t (:inherit font-lock-constant-face :weight bold)))
@@ -717,6 +711,20 @@ running. INTERACTIVE is t if called interactively."
(defvar eglot-editing-mode-map (make-sparse-keymap))
+(defun eglot--maybe-activate-editing-mode (&optional proc)
+ "Maybe activate mode function `eglot-editing-mode'.
+If PROC is supplied, do it only if BUFFER is managed by it. In
+that case, also signal textDocument/didOpen."
+ (when buffer-file-name
+ (let ((cur (eglot--current-process)))
+ (when (or (and (null proc) cur)
+ (and proc (eq proc cur)))
+ (unless eglot-editing-mode
+ (eglot-editing-mode 1))
+ (eglot--signalDidOpen)))))
+
+(add-hook 'find-file-hook 'eglot--maybe-activate-editing-mode)
+
(define-minor-mode eglot-editing-mode
"Minor mode for source buffers where EGLOT helps you edit."
nil
- [elpa] externals/elpa 889ef20 085/139: Tweak the async request engine., (continued)
- [elpa] externals/elpa 889ef20 085/139: Tweak the async request engine., João Távora, 2018/05/14
- [elpa] externals/elpa 1add335 078/139: Workaround two suspected Emacs bugs, João Távora, 2018/05/14
- [elpa] externals/elpa 9d404c9 054/139: Update README.md, João Távora, 2018/05/14
- [elpa] externals/elpa c417eb4 009/139: Cancel timeouts when process dies unexpectedly, João Távora, 2018/05/14
- [elpa] externals/elpa 6689a15 026/139: Add eglot-clear-status interactive command, João Távora, 2018/05/14
- [elpa] externals/elpa 63f2208 030/139: Less obstrusive flymake stuff for now, João Távora, 2018/05/14
- [elpa] externals/elpa 3403f86 027/139: Correctly report what we currently are capable of, João Távora, 2018/05/14
- [elpa] externals/elpa 92bf3a0 038/139: Signal textDocument/didClose, João Távora, 2018/05/14
- [elpa] externals/elpa 7ec0dcf 029/139: Events buffer uses eglot-mode, source buffers use eglot-editing-mode, João Távora, 2018/05/14
- [elpa] externals/elpa 17e0ca4 047/139: Fix Flymake diagnostic positions, João Távora, 2018/05/14
- [elpa] externals/elpa 0e95167 042/139: Watch for files opened under umbrella of existing process,
João Távora <=
- [elpa] externals/elpa 9665a3e 051/139: Fix textDocument/didChange, João Távora, 2018/05/14
- [elpa] externals/elpa 1514e0f 052/139: Fix a couple of Rust-related edge cases, João Távora, 2018/05/14
- [elpa] externals/elpa d90efdf 001/139: Initial commit, João Távora, 2018/05/14
- [elpa] externals/elpa 29d4103 056/139: Fix mode-line mouse-clicks from outside selected window, João Távora, 2018/05/14
- [elpa] externals/elpa ea918ab 066/139: Include source info in diagnostics, João Távora, 2018/05/14
- [elpa] externals/elpa 2b61a3b 048/139: Delete two useless forward declarations, João Távora, 2018/05/14
- [elpa] externals/elpa 7d0bf64 062/139: Workaround RLS's regusal to treat nil as empty json object, João Távora, 2018/05/14
- [elpa] externals/elpa e7ffc31 067/139: Make reported capabilities into its own function, João Távora, 2018/05/14
- [elpa] externals/elpa c2862f4 063/139: Don't auto-reconnect if last attempt lasted less than 3 seconds, João Távora, 2018/05/14
- [elpa] externals/elpa e86f9b4 073/139: New helper eglot--sync-request, João Távora, 2018/05/14