From aea3a00ec898bc46b56266e77bf1060950d5f765 Mon Sep 17 00:00:00 2001 From: Manuel Uberti Date: Sat, 19 Nov 2022 06:20:48 +0100 Subject: [PATCH] Check for live buffer --- flymake-proselint.el | 39 ++++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/flymake-proselint.el b/flymake-proselint.el index 14c7823..04428aa 100644 --- a/flymake-proselint.el +++ b/flymake-proselint.el @@ -292,25 +292,26 @@ Flymake diagnostic objects." (pcase (process-status proc) ('exit (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)))))) + (when (buffer-live-p (current-buffer)) + (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)))) -- 2.45.2