[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot c222c3b 019/139: Lay groundwork for uniform treat
From: |
João Távora |
Subject: |
[elpa] externals/eglot c222c3b 019/139: Lay groundwork for uniform treatment of network connections |
Date: |
Mon, 14 May 2018 09:54:43 -0400 (EDT) |
branch: externals/eglot
commit c222c3bc547ad03764385b2d651297e7c45926dd
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Lay groundwork for uniform treatment of network connections
* eglot.el (eglot--connect): New helper.
(eglot-new-process): Use it.
(pcase): Require it.
---
eglot.el | 62 ++++++++++++++++++++++++++++++++++++--------------------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/eglot.el b/eglot.el
index 9e5f6c2..cd213e7 100644
--- a/eglot.el
+++ b/eglot.el
@@ -29,6 +29,7 @@
(require 'project)
(require 'url-parse)
(require 'url-util)
+(require 'pcase)
(defgroup eglot nil
"Interaction with Language Server Protocol servers"
@@ -97,12 +98,27 @@
major-mode))
probe))
+(defun eglot--connect (name filter sentinel)
+ "Helper for `eglot-new-process'.
+NAME is a name to give the inferior process or connection.
+FILTER and SENTINEL are filter and sentinel.
+Should return a list of (PROCESS BUFFER)."
+ (let ((proc (make-process :name name
+ :buffer (get-buffer-create
+ (format "*%s inferior*" name))
+ :command (eglot--command 'error)
+ :connection-type 'pipe
+ :filter filter
+ :sentinel sentinel
+ :stderr (get-buffer-create (format "*%s stderr*"
+ name)))))
+ (list proc (process-buffer proc))))
+
(defun eglot-new-process (&optional interactive)
"Start a new EGLOT process and initialize it.
INTERACTIVE is t if called interactively."
(interactive (list t))
- (let ((project (project-current))
- (command (eglot--command 'errorp)))
+ (let ((project (project-current)))
(unless project (eglot--error "(new-process) Cannot work without a current
project!"))
(let ((current-process (eglot--current-process)))
(when (and current-process
@@ -114,30 +130,24 @@ INTERACTIVE is t if called interactively."
(car (project-roots (project-current))))))
(good-name
(format "EGLOT server (%s)" short-name)))
- (with-current-buffer (get-buffer-create
- (format "*%s inferior*" good-name))
- (let* ((proc
- (make-process :name good-name
- :buffer (current-buffer)
- :command command
- :connection-type 'pipe
- :filter 'eglot--process-filter
- :sentinel 'eglot--process-sentinel
- :stderr (get-buffer-create (format "*%s stderr*"
- good-name))))
- (inhibit-read-only t))
- (setf (eglot--short-name proc) short-name)
- (puthash (project-current) proc eglot--processes-by-project)
- (erase-buffer)
- (let ((marker (point-marker)))
- (set-marker-insertion-type marker nil)
- (setf (eglot--message-mark proc) marker))
- (read-only-mode t)
- (with-current-buffer (eglot-events-buffer proc)
- (let ((inhibit-read-only t))
- (insert
- (format "\n-----------------------------------\n"))))
- (eglot--protocol-initialize proc interactive))))))
+ (pcase-let ((`(,proc ,buffer)
+ (eglot--connect good-name
+ 'eglot--process-filter
+ 'eglot--process-sentinel)))
+ (with-current-buffer buffer
+ (let ((inhibit-read-only t))
+ (setf (eglot--short-name proc) short-name)
+ (puthash (project-current) proc eglot--processes-by-project)
+ (erase-buffer)
+ (let ((marker (point-marker)))
+ (set-marker-insertion-type marker nil)
+ (setf (eglot--message-mark proc) marker))
+ (read-only-mode t)
+ (with-current-buffer (eglot-events-buffer proc)
+ (let ((inhibit-read-only t))
+ (insert
+ (format "\n-----------------------------------\n"))))
+ (eglot--protocol-initialize proc interactive)))))))
(defun eglot--process-sentinel (process change)
(with-current-buffer (process-buffer process)
- [elpa] branch externals/eglot created (now 4c0bfc3), João Távora, 2018/05/14
- [elpa] externals/eglot 3a8f9a1 002/139: Remove a couple of comments, João Távora, 2018/05/14
- [elpa] externals/eglot 72895ca 006/139: Handle notifications, João Távora, 2018/05/14
- [elpa] externals/eglot 0222e7e 007/139: Improve `eglot--current-process', João Távora, 2018/05/14
- [elpa] externals/eglot 2775dea 003/139: Rename eglot--continuations eglot--pending-continuations, João Távora, 2018/05/14
- [elpa] externals/eglot c417eb4 009/139: Cancel timeouts when process dies unexpectedly, João Távora, 2018/05/14
- [elpa] externals/eglot 6f0a8df 008/139: Organize a bit, João Távora, 2018/05/14
- [elpa] externals/eglot c222c3b 019/139: Lay groundwork for uniform treatment of network connections,
João Távora <=
- [elpa] externals/eglot 3489176 004/139: Add a mode-line construct and some minor fanciness, João Távora, 2018/05/14
- [elpa] externals/eglot dfab9a0 011/139: Experimental diagnostic overlays, João Távora, 2018/05/14
- [elpa] externals/eglot 16be2fc 020/139: Fix parser to accept multiple messages in one chunk, João Távora, 2018/05/14
- [elpa] externals/eglot 0ec7801 012/139: Simplify `eglot--protocol-initialize`, João Távora, 2018/05/14
- [elpa] externals/eglot 4f246b5 017/139: * eglot.el (eglot-mode-map): Move up before minor mode., João Távora, 2018/05/14
- [elpa] externals/eglot bc011d0 010/139: Minor cleanup, João Távora, 2018/05/14
- [elpa] externals/eglot e60c7fc 013/139: Overhaul async mechanism safety, João Távora, 2018/05/14
- [elpa] externals/eglot a4f99e0 005/139: Introduce and use `eglot--current-process-or-lose', João Távora, 2018/05/14
- [elpa] externals/eglot efd14d6 015/139: Fix mode line, João Távora, 2018/05/14
- [elpa] externals/eglot 63f2208 030/139: Less obstrusive flymake stuff for now, João Távora, 2018/05/14