From c22242b284e4a42ac4a4056b17b5f1580baa339d Mon Sep 17 00:00:00 2001 From: 10sr <8.slashes@gmail.com> Date: Wed, 30 Jan 2019 14:51:36 +0900 Subject: [PATCH] Add --- emacs.el | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/emacs.el b/emacs.el index f3bffbb..9fc9f53 100644 --- a/emacs.el +++ b/emacs.el @@ -2062,21 +2062,31 @@ initializing." (add-to-list 'flycheck-checkers 'python-black-check) -;; Fix when file has invalid syntax (defun flycheck-parse-black-check (output checker buffer) "Flycheck parser to check if reformat is required." (with-temp-buffer (insert output) (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 reformat buffer" - :buffer buffer - :checker checker))))) + (save-match-data + (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))) + (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))) + ))) (defun my-flycheck-parse-unified-diff (output checker buffer) "Flycheck parser to parse diff output."