[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/flymake-proselint 3a475ee7fe 1/3: Avoid selecting dead
From: |
ELPA Syncer |
Subject: |
[elpa] externals/flymake-proselint 3a475ee7fe 1/3: Avoid selecting dead buffers |
Date: |
Sun, 13 Nov 2022 13:57:42 -0500 (EST) |
branch: externals/flymake-proselint
commit 3a475ee7fe187d1c4744dc9826b1adbd669b69c4
Author: Manuel Uberti <manuel.uberti@inventati.org>
Commit: Manuel Uberti <manuel.uberti@inventati.org>
Avoid selecting dead buffers
---
flymake-proselint.el | 58 +++++++++++++++++++++++++++-------------------------
1 file changed, 30 insertions(+), 28 deletions(-)
diff --git a/flymake-proselint.el b/flymake-proselint.el
index 0e944a6f8c..113b1b3a1a 100644
--- a/flymake-proselint.el
+++ b/flymake-proselint.el
@@ -287,34 +287,36 @@ Flymake diagnostic objects."
"Sentinel on PROC for handling Proselint response.
A successfully parsed message is passed onto the function
`flymake-proselint-sentinel-1' for further handling."
- (pcase (process-status proc)
- ('exit
- (let ((report-fn (process-get proc 'report-fn))
- (source (process-get proc 'source)))
- (unwind-protect
- (with-current-buffer (process-buffer proc)
- (goto-char (point-min))
- (cond
- ((with-current-buffer source
- (not (eq proc flymake-proselint--flymake-proc)))
- (flymake-log :warning "Canceling obsolete check %s" proc))
- ((= (point-max) (point-min))
- (flymake-log :debug "Empty response"))
- ((condition-case err
- (let ((response (json-parse-buffer :object-type 'plist
- :array-type 'list)))
- (if (string= (plist-get response :status) "success")
- (thread-last
- (plist-get response :data)
- (flymake-proselint-sentinel-1 source)
- (funcall report-fn))
- (flymake-log :error "Check failed")))
- (json-parse-error
- (flymake-log :error "Invalid response: %S" err))))))
- (with-current-buffer source
- (setq flymake-proselint--flymake-proc nil))
- (kill-buffer (process-buffer proc)))))
- ('signal (kill-buffer (process-buffer proc)))))
+ (let ((buffer (process-buffer proc)))
+ (when (buffer-live-p buffer)
+ (pcase (process-status proc)
+ ('exit
+ (let ((report-fn (process-get proc 'report-fn))
+ (source (process-get proc 'source)))
+ (unwind-protect
+ (with-current-buffer buffer
+ (goto-char (point-min))
+ (cond
+ ((with-current-buffer source
+ (not (eq proc flymake-proselint--flymake-proc)))
+ (flymake-log :warning "Canceling obsolete check %s" proc))
+ ((= (point-max) (point-min))
+ (flymake-log :debug "Empty response"))
+ ((condition-case err
+ (let ((response (json-parse-buffer :object-type 'plist
+ :array-type 'list)))
+ (if (string= (plist-get response :status) "success")
+ (thread-last
+ (plist-get response :data)
+ (flymake-proselint-sentinel-1 source)
+ (funcall report-fn))
+ (flymake-log :error "Check failed")))
+ (json-parse-error
+ (flymake-log :error "Invalid response: %S" err))))))
+ (with-current-buffer source
+ (setq flymake-proselint--flymake-proc nil))
+ (kill-buffer buffer))))
+ ('signal (kill-buffer buffer))))))
(defun flymake-proselint-backend (report-fn &rest _args)
"Flymake backend for Proselint.