[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot a4f99e0 005/139: Introduce and use `eglot--curren
From: |
João Távora |
Subject: |
[elpa] externals/eglot a4f99e0 005/139: Introduce and use `eglot--current-process-or-lose' |
Date: |
Mon, 14 May 2018 09:54:41 -0400 (EDT) |
branch: externals/eglot
commit a4f99e09d3a4eaafb1d59875f0d314549a104137
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Introduce and use `eglot--current-process-or-lose'
---
eglot.el | 83 +++++++++++++++++++++++++++++++++++-----------------------------
1 file changed, 45 insertions(+), 38 deletions(-)
diff --git a/eglot.el b/eglot.el
index 92c1216..5ca6833 100644
--- a/eglot.el
+++ b/eglot.el
@@ -45,12 +45,16 @@
(eglot--error "No current project, so no process"))
(gethash cur eglot--processes-by-project)))
+(defun eglot--current-process-or-lose ()
+ (or (eglot--current-process)
+ (eglot--error "No current EGLOT process")))
+
(defmacro eglot--define-process-var (var-sym initval &optional doc)
(declare (indent 2))
`(progn
(put ',var-sym 'function-documentation ,doc)
(defun ,var-sym (&optional process)
- (let* ((proc (or process (eglot--current-process)))
+ (let* ((proc (or process (eglot--current-process-or-lose)))
(probe (process-get proc ',var-sym)))
(or probe
(let ((def ,initval))
@@ -58,7 +62,7 @@
def))))
(gv-define-setter ,var-sym (to-store &optional process)
(let ((prop ',var-sym))
- `(let ((proc (or ,process (eglot--current-process))))
+ `(let ((proc (or ,process (eglot--current-process-or-lose))))
(process-put proc ',prop ,to-store))))))
(eglot--define-process-var eglot--message-mark nil
@@ -103,7 +107,7 @@
major-mode))
probe))
-(defun eglot-new-process (&optional _interactive)
+(defun eglot-new-process (&optional interactive)
"Starts a new EGLOT process and initializes it"
(interactive (list t))
(let ((project (project-current))
@@ -141,10 +145,10 @@
(let ((inhibit-read-only t))
(insert
(format "\n-----------------------------------\n"))))
- (eglot--protocol-initialize proc))))))
+ (eglot--protocol-initialize proc interactive))))))
(defun eglot-quit-server (process &optional sync)
- (interactive (list (eglot--current-process)))
+ (interactive (list (eglot--current-process-or-lose)))
(eglot--message "Asking server to terminate")
(eglot--request
process
@@ -238,7 +242,7 @@
)))))))
(defun eglot-events-buffer (process &optional interactive)
- (interactive (list (eglot--current-process) t))
+ (interactive (list (eglot--current-process-or-lose) t))
(let* ((probe (eglot--events-buffer process))
(buffer (or (and (buffer-live-p probe)
probe)
@@ -302,7 +306,7 @@
(setq eglot--next-request-id (1+ eglot--next-request-id)))
(defun eglot-forget-pending-continuations (process)
- (interactive (eglot--current-process))
+ (interactive (eglot--current-process-or-lose))
(clrhash (eglot--pending-continuations process)))
(defun eglot--call-with-request (process
@@ -350,38 +354,41 @@
(accept-process-output nil 0.01))))))
-(defun eglot--protocol-initialize (process)
+(defun eglot--protocol-initialize (process interactive)
(eglot--request
- process
- :initialize
- `(:processId ,(emacs-pid)
- :rootPath ,(concat "" ;; FIXME RLS doesn't like "file://"
- (expand-file-name (car (project-roots
-
(project-current)))))
- :initializationOptions []
- :capabilities (:workspace (:executeCommand
(:dynamicRegistration t))
- :textDocument (:synchronization
(:didSave t)))
- )
- (lambda (&key capabilities)
- (cl-destructuring-bind
- (&rest all
- &key
- _textDocumentSync
- _hoverProvider
- _completionProvider
- _definitionProvider
- _referencesProvider
- _documentHighlightProvider
- _documentSymbolProvider
- _workspaceSymbolProvider
- _codeActionProvider
- _documentFormattingProvider
- _documentRangeFormattingProvider
- _renameProvider
- _executeCommandProvider
- )
- capabilities
- (message "so yeah I got lots (%d) of capabilities" (length all))))))
+ process
+ :initialize
+ `(:processId ,(emacs-pid)
+ :rootPath ,(concat "" ;; FIXME RLS doesn't like "file://"
+ (expand-file-name (car (project-roots
+
(project-current)))))
+ :initializationOptions []
+ :capabilities (:workspace (:executeCommand
(:dynamicRegistration t))
+ :textDocument (:synchronization
(:didSave t))))
+ (lambda (&key capabilities)
+ (cl-destructuring-bind
+ (&rest all
+ &key
+ ;; capabilities reported by server
+ _textDocumentSync
+ _hoverProvider
+ _completionProvider
+ _definitionProvider
+ _referencesProvider
+ _documentHighlightProvider
+ _documentSymbolProvider
+ _workspaceSymbolProvider
+ _codeActionProvider
+ _documentFormattingProvider
+ _documentRangeFormattingProvider
+ _renameProvider
+ _executeCommandProvider
+ )
+ capabilities
+ (when interactive
+ (eglot--message
+ "So yeah I got lots (%d) of capabilities"
+ (length all)))))))
(defun eglot--debug (format &rest args)
(display-warning 'eglot
- [elpa] externals/eglot c417eb4 009/139: Cancel timeouts when process dies unexpectedly, (continued)
- [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, 2018/05/14
- [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 <=
- [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
- [elpa] externals/eglot 8bd634c 016/139: Start working on this again, João Távora, 2018/05/14
- [elpa] externals/eglot 3403f86 027/139: Correctly report what we currently are capable of, João Távora, 2018/05/14
- [elpa] externals/eglot 7c82a03 024/139: Start experimenting with python, João Távora, 2018/05/14
- [elpa] externals/eglot 8e6488f 023/139: Don't switch to possibly dead buffer in sentinel, João Távora, 2018/05/14
- [elpa] externals/eglot e1d36d2 014/139: Fix some byte-compilation warnings, João Távora, 2018/05/14
- [elpa] externals/eglot 6f6f01d 018/139: Doc fixes, João Távora, 2018/05/14
- [elpa] externals/eglot 7ec0dcf 029/139: Events buffer uses eglot-mode, source buffers use eglot-editing-mode, João Távora, 2018/05/14
- [elpa] externals/eglot 22dc2f7 034/139: Ready to start fixing flymake integration, João Távora, 2018/05/14