Browse Source

Add

master
10sr 5 years ago
parent
commit
c22242b284
Signed by: 10sr GPG Key ID: 7BEC428194130EB2
1 changed files with 20 additions and 10 deletions
  1. +20
    -10
      emacs.el

+ 20
- 10
emacs.el View File

@@ -2062,21 +2062,31 @@ initializing."
(add-to-list 'flycheck-checkers (add-to-list 'flycheck-checkers
'python-black-check) 'python-black-check)


;; Fix when file has invalid syntax
(defun flycheck-parse-black-check (output checker buffer) (defun flycheck-parse-black-check (output checker buffer)
"Flycheck parser to check if reformat is required." "Flycheck parser to check if reformat is required."
(with-temp-buffer (with-temp-buffer
(insert output) (insert output)
(goto-char (point-min)) (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) (defun my-flycheck-parse-unified-diff (output checker buffer)
"Flycheck parser to parse diff output." "Flycheck parser to parse diff output."


Loading…
Cancel
Save