[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/elpa 29f58a6 127/139: Get rid of catch/loop/throw idiom
From: |
João Távora |
Subject: |
[elpa] externals/elpa 29f58a6 127/139: Get rid of catch/loop/throw idiom (suggested by Thien-Thi Nguyen) |
Date: |
Mon, 14 May 2018 09:53:49 -0400 (EDT) |
branch: externals/elpa
commit 29f58a6514aec28e4e6df9611e4f58c7289e3cc6
Author: João Távora <address@hidden>
Commit: João Távora <address@hidden>
Get rid of catch/loop/throw idiom (suggested by Thien-Thi Nguyen)
* eglot.el (eglot--process-filter)
(eglot--request): Replace catch/loop/throw idiom with let/test/loop/set
---
eglot.el | 44 +++++++++++++++++++-------------------------
1 file changed, 19 insertions(+), 25 deletions(-)
diff --git a/eglot.el b/eglot.el
index aabaf54..c8612cf 100644
--- a/eglot.el
+++ b/eglot.el
@@ -400,8 +400,7 @@ INTERACTIVE is t if called interactively."
(when (buffer-live-p (process-buffer proc))
(with-current-buffer (process-buffer proc)
(let ((inhibit-read-only t)
- (expected-bytes (eglot--expected-bytes proc))
- (done (make-symbol "eglot--process-filter-done-tag")))
+ (expected-bytes (eglot--expected-bytes proc)))
;; Insert the text, advancing the process marker.
;;
(save-excursion
@@ -411,8 +410,8 @@ INTERACTIVE is t if called interactively."
;; Loop (more than one message might have arrived)
;;
(unwind-protect
- (catch done
- (while t
+ (let (done)
+ (while (not done)
(cond
((not expected-bytes)
;; Starting a new message
@@ -425,7 +424,7 @@ INTERACTIVE is t if called interactively."
t)
(string-to-number (match-string 1))))
(unless expected-bytes
- (throw done :waiting-for-new-message)))
+ (setq done :waiting-for-new-message)))
(t
;; Attempt to complete a message body
;;
@@ -453,7 +452,7 @@ INTERACTIVE is t if called interactively."
(t
;; Message is still incomplete
;;
- (throw done
:waiting-for-more-bytes-in-this-message))))))))
+ (setq done
:waiting-for-more-bytes-in-this-message))))))))
;; Saved parsing state for next visit to this filter
;;
(setf (eglot--expected-bytes proc) expected-bytes))))))
@@ -652,25 +651,20 @@ DEFERRED is passed to `eglot--async-request', which see."
;; bad idea, since that might lead to the request never having a
;; chance to run, because `eglot--ready-predicates'.
(when deferred (eglot--signal-textDocument/didChange))
- (let* ((done (make-symbol "eglot--request-catch-tag"))
- (res
- (catch done (eglot--async-request
- proc method params
- :success-fn (lambda (&rest args)
- (throw done (if (vectorp (car args))
- (car args) args)))
- :error-fn (eglot--lambda
- (&key code message &allow-other-keys)
- (throw done
- `(error ,(format "Oops: %s: %s"
- code message))))
- :timeout-fn (lambda ()
- (throw done '(error "Timed out")))
- :deferred deferred)
- ;; now spin, baby!
- (while t (accept-process-output nil 0.01)))))
- (when (and (listp res) (eq 'error (car res))) (eglot--error (cadr res)))
- res))
+ (let ((retval))
+ (eglot--async-request
+ proc method params
+ :success-fn (lambda (&rest args)
+ (setq retval `(done ,(if (vectorp (car args))
+ (car args) args))))
+ :error-fn (eglot--lambda (&key code message &allow-other-keys)
+ (setq retval `(error ,(format "Oops: %s: %s" code message))))
+ :timeout-fn (lambda ()
+ (setq retval '(error "Timed out")))
+ :deferred deferred)
+ (while (not retval) (accept-process-output nil 30))
+ (when (eq 'error (car retval)) (eglot--error (cadr retval)))
+ (cadr retval)))
(cl-defun eglot--notify (process method params)
"Notify PROCESS of something, don't expect a reply.e"
- [elpa] externals/elpa 3a6c637 099/139: Support textDocument/rename, (continued)
- [elpa] externals/elpa 3a6c637 099/139: Support textDocument/rename, João Távora, 2018/05/14
- [elpa] externals/elpa 458bc69 110/139: More correctly setup rust-mode-related autoloads, João Távora, 2018/05/14
- [elpa] externals/elpa 3dcbc30 109/139: Add minimal headers, commentary and autoloads, João Távora, 2018/05/14
- [elpa] externals/elpa 581608f 115/139: Resist server failure during synchronous requests, João Távora, 2018/05/14
- [elpa] externals/elpa 41f5922 137/139: Now send willSaveWaitUntil, João Távora, 2018/05/14
- [elpa] externals/elpa 05c67ee 112/139: Adjust flymake integration, João Távora, 2018/05/14
- [elpa] externals/elpa f89f859 114/139: Simplify mode-line updating logic, João Távora, 2018/05/14
- [elpa] externals/elpa 0625b6c 123/139: (eglot--xref-make): Fix Use of cl-destructuring-bind., João Távora, 2018/05/14
- [elpa] externals/elpa 56cf02d 126/139: Rework autoreconnection logic, João Távora, 2018/05/14
- [elpa] externals/elpa 49fb02f 135/139: Use RLS in Travis CI and add actual tests, João Távora, 2018/05/14
- [elpa] externals/elpa 29f58a6 127/139: Get rid of catch/loop/throw idiom (suggested by Thien-Thi Nguyen),
João Távora <=
- [elpa] externals/elpa 418412b 131/139: Fix copyright header. Obviously not since 2003, João Távora, 2018/05/14
- [elpa] externals/elpa 54fc885 113/139: More RLS-specifics: update Flymake diags when indexing done, João Távora, 2018/05/14
- [elpa] externals/elpa 8a80fb7 105/139: Simplify `eglot-shutdown`, João Távora, 2018/05/14
- [elpa] externals/elpa d40f9ac 094/139: Half-decent imenu support via textDocument/documentSymbol, João Távora, 2018/05/14
- [elpa] externals/elpa 42177d0 107/139: New "deferred requests" that wait until server is ready, João Távora, 2018/05/14
- [elpa] externals/elpa ef80455 121/139: Support :completionItem/resolve, João Távora, 2018/05/14
- [elpa] externals/elpa 77856c2 130/139: Reinstate the catch/loop/throw idiom in eglot-request, João Távora, 2018/05/14
- [elpa] externals/elpa d1cdcf1 119/139: Friendlier M-x eglot, João Távora, 2018/05/14
- [elpa] externals/elpa 4c0bfc3 139/139: Support didChangeWatchedFiles with dynamic registration, João Távora, 2018/05/14
- [elpa] externals/elpa fceb6bb 090/139: Get rid of eglot--special-buffer-process, João Távora, 2018/05/14