[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/plz f551c1bd49 25/40: Tidy: (plz--respond)
From: |
ELPA Syncer |
Subject: |
[elpa] externals/plz f551c1bd49 25/40: Tidy: (plz--respond) |
Date: |
Mon, 26 Jun 2023 06:59:33 -0400 (EDT) |
branch: externals/plz
commit f551c1bd49c2f0725f7d6810feecf3ddbe1cd385
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>
Tidy: (plz--respond)
---
plz.el | 105 ++++++++++++++++++++++++++++++++---------------------------------
1 file changed, 51 insertions(+), 54 deletions(-)
diff --git a/plz.el b/plz.el
index 6586942b1a..e7cb9b06de 100644
--- a/plz.el
+++ b/plz.el
@@ -747,60 +747,57 @@ argument passed to `plz--sentinel', which see."
;; "Respond" also means "to react to something," which is what this
;; does--react to receiving the HTTP response--and it's an internal
;; name, so why not.
- (let ((finally (buffer-local-value 'plz-finally buffer))
- sync)
- (unwind-protect
- (with-current-buffer buffer
- (setf sync plz-sync)
- (pcase-exhaustive status
- ((or 0 "finished\n")
- ;; Curl exited normally: check HTTP status code.
- (goto-char (point-min))
- (plz--skip-proxy-headers)
- (while (plz--skip-redirect-headers))
- (pcase (plz--http-status)
- ((and status (guard (<= 200 status 299)))
- ;; Any 2xx response is considered successful.
- (ignore status) ; Byte-compiling in Emacs <28 complains
without this.
- (funcall plz-then))
- (_
- ;; TODO: If using ":as 'response", the HTTP response
- ;; should be passed to the THEN function, regardless
- ;; of the status code. Only for curl errors should
- ;; the ELSE function be called. (Maybe in v0.8.)
-
- ;; Any other status code is considered unsuccessful
- ;; (for now, anyway).
- (let ((err (make-plz-error :response (plz--response))))
- (pcase-exhaustive plz-else
- (`nil (process-put process :plz-result err))
- ((pred functionp) (funcall plz-else err)))))))
-
- ((or (and (pred numberp) code)
- (rx "exited abnormally with code " (let code (group (1+
digit)))))
- ;; Curl error.
- (let* ((curl-exit-code (cl-typecase code
- (string (string-to-number code))
- (number code)))
- (curl-error-message (alist-get curl-exit-code
plz-curl-errors))
- (err (make-plz-error :curl-error (cons curl-exit-code
curl-error-message))))
- (pcase-exhaustive plz-else
- (`nil (process-put process :plz-result err))
- ((pred functionp) (funcall plz-else err)))))
-
- ((and (or "killed\n" "interrupt\n") status)
- ;; Curl process killed or interrupted.
- (let* ((message (pcase status
- ("killed\n" "curl process killed")
- ("interrupt\n" "curl process interrupted")))
- (err (make-plz-error :message message)))
- (pcase-exhaustive plz-else
- (`nil (process-put process :plz-result err))
- ((pred functionp) (funcall plz-else err)))))))
- (when finally
- (funcall finally))
- (unless sync
- (kill-buffer buffer)))))
+ (unwind-protect
+ (with-current-buffer buffer
+ (pcase-exhaustive status
+ ((or 0 "finished\n")
+ ;; Curl exited normally: check HTTP status code.
+ (goto-char (point-min))
+ (plz--skip-proxy-headers)
+ (while (plz--skip-redirect-headers))
+ (pcase (plz--http-status)
+ ((and status (guard (<= 200 status 299)))
+ ;; Any 2xx response is considered successful.
+ (ignore status) ; Byte-compiling in Emacs <28 complains without
this.
+ (funcall plz-then))
+ (_
+ ;; TODO: If using ":as 'response", the HTTP response
+ ;; should be passed to the THEN function, regardless
+ ;; of the status code. Only for curl errors should
+ ;; the ELSE function be called. (Maybe in v0.8.)
+
+ ;; Any other status code is considered unsuccessful
+ ;; (for now, anyway).
+ (let ((err (make-plz-error :response (plz--response))))
+ (pcase-exhaustive plz-else
+ (`nil (process-put process :plz-result err))
+ ((pred functionp) (funcall plz-else err)))))))
+
+ ((or (and (pred numberp) code)
+ (rx "exited abnormally with code " (let code (group (1+
digit)))))
+ ;; Curl error.
+ (let* ((curl-exit-code (cl-typecase code
+ (string (string-to-number code))
+ (number code)))
+ (curl-error-message (alist-get curl-exit-code
plz-curl-errors))
+ (err (make-plz-error :curl-error (cons curl-exit-code
curl-error-message))))
+ (pcase-exhaustive plz-else
+ (`nil (process-put process :plz-result err))
+ ((pred functionp) (funcall plz-else err)))))
+
+ ((and (or "killed\n" "interrupt\n") status)
+ ;; Curl process killed or interrupted.
+ (let* ((message (pcase status
+ ("killed\n" "curl process killed")
+ ("interrupt\n" "curl process interrupted")))
+ (err (make-plz-error :message message)))
+ (pcase-exhaustive plz-else
+ (`nil (process-put process :plz-result err))
+ ((pred functionp) (funcall plz-else err)))))))
+ (when-let ((finally (buffer-local-value 'plz-finally buffer)))
+ (funcall finally))
+ (unless (buffer-local-value 'plz-sync buffer)
+ (kill-buffer buffer))))
;;;;;; HTTP Responses
- [elpa] externals/plz 50d977288e 04/40: Fix: Set stderr process sentinel to #'ignore, (continued)
- [elpa] externals/plz 50d977288e 04/40: Fix: Set stderr process sentinel to #'ignore, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 0d4356640d 05/40: Change: Use only one error type, plz-error, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 046f29a816 08/40: Docs: Remove old TODO, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 81d1c61f1f 07/40: Tidy docstring and comment, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 56c92ff78e 12/40: Tidy, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 43231ac43c 14/40: WIP: Use timer for response parsing, ELPA Syncer, 2023/06/26
- [elpa] externals/plz d6dfe3b27a 11/40: Tidy: Remove plz-result, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 85ac0fbe38 15/40: WIP: Use sentinel value; add comments, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 7d197e968a 20/40: Change: (plz--respond) Don't catch errors from THEN/ELSE, ELPA Syncer, 2023/06/26
- [elpa] externals/plz a2c20b1437 24/40: Comment: TODO, ELPA Syncer, 2023/06/26
- [elpa] externals/plz f551c1bd49 25/40: Tidy: (plz--respond),
ELPA Syncer <=
- [elpa] externals/plz de8e21f81d 29/40: Tidy: Docstrings, ELPA Syncer, 2023/06/26
- [elpa] externals/plz f9f95a8544 34/40: Comment: Add TODO, ELPA Syncer, 2023/06/26
- [elpa] externals/plz c786bbf7d2 35/40: Tidy/Comment, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 438162db4e 13/40: WIP: Add request args to sentinel error, ELPA Syncer, 2023/06/26
- [elpa] externals/plz a1f8a10b0b 16/40: Comment: Add FIXME, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 880223e7c0 22/40: Tidy: (plz--sentinel), ELPA Syncer, 2023/06/26
- [elpa] externals/plz 53ef6a16ce 26/40: Comment: Tidy, ELPA Syncer, 2023/06/26
- [elpa] externals/plz 582f0c5bb8 31/40: Tests: Enable continue-on-error for linting, ELPA Syncer, 2023/06/26
- [elpa] externals/plz b896c41d71 32/40: Change: Generate buffer for STDERR, ELPA Syncer, 2023/06/26
- [elpa] externals/plz d2a7368699 37/40: Tidy: (plz) Don't switch to process-buffer, ELPA Syncer, 2023/06/26