From 962d33ba68aa7ca9c7015e2fe5dd539905a067d5 Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Mon, 4 Feb 2019 14:07:55 +0900 Subject: [PATCH] Fix black-check flycheck parser --- emacs.el | 49 +++++++++++++++++++++++++------------------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/emacs.el b/emacs.el index 2ba71fa..7e8aef3 100644 --- a/emacs.el +++ b/emacs.el @@ -2064,30 +2064,31 @@ initializing." (defun flycheck-parse-black-check (output checker buffer) "Flycheck parser to check if reformat is required." - (with-temp-buffer - (insert output) - (save-match-data - (goto-char (point-min)) - (when (re-search-forward "^would reformat .*$" nil t) - (list (flycheck-error-new-at - (point-min) - nil - 'error - ;;(format "Black: %s" (match-string 0)) - "Black: would be reformatted" - :buffer buffer - :checker checker))) - (goto-char (point-min)) - (when (re-search-forward "^error: cannot format .*$" nil t) - (list (flycheck-error-new-at - (point-min) - nil - 'error - ;; Fix not to include absolute file path - (format "Black: %s" (match-string 0)) - :buffer buffer - :checker checker))) - ))) + (let ((result nil)) + (with-temp-buffer + (insert output) + (save-match-data + (goto-char (point-min)) + (when (re-search-forward "^would reformat .*$" nil t) + (setq result (list (flycheck-error-new-at + (point-min) + nil + 'error + ;;(format "Black: %s" (match-string 0)) + "Black: would be reformatted" + :buffer buffer + :checker checker)))) + (goto-char (point-min)) + (when (re-search-forward "^error: cannot format .*$" nil t) + (setq reslt (list (flycheck-error-new-at + (point-min) + nil + 'error + ;; Fix not to include absolute file path + (format "Black: %s" (match-string 0)) + :buffer buffer + :checker checker)))))) + result)) (defun my-flycheck-parse-unified-diff (output checker buffer) "Flycheck parser to parse diff output."