[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/eglot e86f9b4 073/139: New helper eglot--sync-request
From: |
João Távora |
Subject: |
[elpa] externals/eglot e86f9b4 073/139: New helper eglot--sync-request |
Date: |
Mon, 14 May 2018 09:54:56 -0400 (EDT) |
branch: externals/eglot
commit e86f9b41beab44bfa3ab7c75882baa7eb80be46b
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
New helper eglot--sync-request
This should help with xref definitions
* eglot.el (eglot--request): Rework a bit. Continuation is always
cleared on timeout, regardless of user-supplied fn.
(eglot--sync-request): New function.
(eglot--process-receive): watch out for vector results.
---
eglot.el | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/eglot.el b/eglot.el
index 2afb0e7..34ce0f8 100644
--- a/eglot.el
+++ b/eglot.el
@@ -546,7 +546,10 @@ identifier. ERROR is non-nil if this is a JSON-RPC error."
(remhash id (eglot--pending-continuations proc))
(if err
(apply (cl-second continuations) err)
- (apply (cl-first continuations) (plist-get message :result))))
+ (let ((res (plist-get message :result)))
+ (if (listp res)
+ (apply (cl-first continuations) res)
+ (funcall (cl-first continuations) res)))))
(id
(eglot--warn "Ooops no continuation for id %s" id)))))
@@ -592,8 +595,7 @@ identifier. ERROR is non-nil if this is a JSON-RPC error."
(or timeout-fn
(lambda ()
(eglot--warn
- "(request) Tired of waiting for reply to %s" id)
- (remhash id (eglot--pending-continuations process)))))
+ "(request) Tired of waiting for reply to %s" id))))
(error-fn
(or error-fn
(cl-function
@@ -618,11 +620,15 @@ identifier. ERROR is non-nil if this is a JSON-RPC
error."
:params params))
(catch catch-tag
(let ((timeout-timer
- (run-with-timer 5 nil
- (if async-p
- timeout-fn
- (lambda ()
- (throw catch-tag (funcall timeout-fn)))))))
+ (run-with-timer
+ 5 nil
+ (if async-p
+ (lambda ()
+ (remhash id (eglot--pending-continuations process))
+ (funcall timeout-fn))
+ (lambda ()
+ (remhash id (eglot--pending-continuations process))
+ (throw catch-tag (funcall timeout-fn)))))))
(puthash id
(list (if async-p
success-fn
@@ -651,6 +657,23 @@ identifier. ERROR is non-nil if this is a JSON-RPC error."
"(request) Last-change cancelling timer for continuation %s" id)
(cancel-timer timeout-timer))))))))
+(defun eglot--sync-request (proc method params)
+ "Like `eglot--request' for PROC, METHOD and PARAMS, but synchronous.
+Meaning only return locally if successful, otherwise exit non-locally."
+ (eglot--request proc method params
+ :success-fn (lambda (&rest args)
+ (if (vectorp (car args))
+ (car args)
+ args))
+ :error-fn (cl-function
+ (lambda (&key code message &allow-other-keys)
+ (eglot--error "Oops: %s: %s" code message)))
+ :timeout-fn (lambda ()
+ (lambda ()
+ (eglot--error
+ "Tired of waiting for reply to sync
request")))
+ :async-p nil))
+
(cl-defun eglot--notify (process method params)
"Notify PROCESS of something, don't expect a reply.e"
(eglot--process-send nil
- [elpa] externals/eglot e7ffc31 067/139: Make reported capabilities into its own function, (continued)
- [elpa] externals/eglot e7ffc31 067/139: Make reported capabilities into its own function, João Távora, 2018/05/14
- [elpa] externals/eglot 79a2a1e 069/139: Be quite explicit about our lack of capabilities right now, João Távora, 2018/05/14
- [elpa] externals/eglot 95187cf 058/139: Connect to LSP server via TCP, João Távora, 2018/05/14
- [elpa] externals/eglot f76f04e 057/139: More correctly keep track of didOpen/didClose per buffer, João Távora, 2018/05/14
- [elpa] externals/eglot 46bb1c0 049/139: Reorganize file, João Távora, 2018/05/14
- [elpa] externals/eglot ff5a03d 074/139: Very basic xref support, João Távora, 2018/05/14
- [elpa] externals/eglot e9b5e54 077/139: ETOOMANYLAMBDAS, João Távora, 2018/05/14
- [elpa] externals/eglot dda11dd 095/139: Try to fix some textDocument/completion bugs, João Távora, 2018/05/14
- [elpa] externals/eglot ea918ab 066/139: Include source info in diagnostics, João Távora, 2018/05/14
- [elpa] externals/eglot a199c8e 070/139: Honour textDocumentSync, João Távora, 2018/05/14
- [elpa] externals/eglot e86f9b4 073/139: New helper eglot--sync-request,
João Távora <=
- [elpa] externals/eglot 1add335 078/139: Workaround two suspected Emacs bugs, João Távora, 2018/05/14
- [elpa] externals/eglot 889ef20 085/139: Tweak the async request engine., João Távora, 2018/05/14
- [elpa] externals/eglot 193c57d 075/139: Half-decent xref support, João Távora, 2018/05/14
- [elpa] externals/eglot fc6879f 084/139: Explain why didOpen on after-revert-hook is a bad idea, João Távora, 2018/05/14
- [elpa] externals/eglot 24466a9 096/139: When killing server, always wait 3 seconds, João Távora, 2018/05/14
- [elpa] externals/eglot fceb6bb 090/139: Get rid of eglot--special-buffer-process, João Távora, 2018/05/14
- [elpa] externals/eglot d254f97 082/139: Solve another textDocument/didChange bug, João Távora, 2018/05/14
- [elpa] externals/eglot f257d63 089/139: * eglot.el: Reformat to shave off some lines., João Távora, 2018/05/14
- [elpa] externals/eglot c7bd095 118/139: Improve eglot-eldoc-function, João Távora, 2018/05/14
- [elpa] externals/eglot 3e0f1c3 122/139: Misc little adjustments for readability, João Távora, 2018/05/14