fix(emacs/lean-flycheck): fix bug in advice for lean-flycheck-try-parse-error-with-pattern
I provided an "advice" for 'flycheck-try-parse-error-with-pattern' function to change its behavior, namely to increase error-columns by one. Bug === The problem is that it doesn't consider the case where the pattern is not matched and ends up with "err = nil". For this case, "(flycheck-error-column err)" generates an exception if executed. The whole error parsing process stops immediately. This causes a problem when we have more than one error-patterns, which is the case when we enable 'error' and 'warning' patterns. Fix === Fix is simple: check err before executing (flycheck-error-column err) - (col (flycheck-error-column err))) + (col (and err (flycheck-error-column err))))
This commit is contained in:
parent
d81a6259e8
commit
fe638f0ee7
1 changed files with 3 additions and 13 deletions
|
@ -29,25 +29,15 @@
|
||||||
"A Lean syntax checker."
|
"A Lean syntax checker."
|
||||||
:command ,(lean-flycheck-command)
|
:command ,(lean-flycheck-command)
|
||||||
:error-patterns
|
:error-patterns
|
||||||
;; ((error line-start "FLYCHECK_BEGIN ERROR" (? "\r") "\n"
|
|
||||||
;; (file-name) ":" line ":" (? column ":") " error: "
|
|
||||||
;; (minimal-match
|
|
||||||
;; (message (+ (+ not-newline) (? "\r") "\n")))
|
|
||||||
;; "FLYCHECK_END" line-end)
|
|
||||||
;; (warning line-start "FLYCHECK_BEGIN WARNING" (? "\r") "\n"
|
|
||||||
;; (file-name) ":" line ":" (? column ":") " warning "
|
|
||||||
;; (minimal-match
|
|
||||||
;; (message (+ (* not-newline) (? "\r") "\n") ))
|
|
||||||
;; "FLYCHECK_END" line-end))
|
|
||||||
((error line-start "FLYCHECK_BEGIN ERROR" (? "\r") "\n"
|
((error line-start "FLYCHECK_BEGIN ERROR" (? "\r") "\n"
|
||||||
(file-name) ":" line ":" (? column ":") " error: "
|
(file-name) ":" line ":" (? column ":") " error: "
|
||||||
(minimal-match
|
(minimal-match
|
||||||
(message (one-or-more (zero-or-more not-newline) (? "\r") "\n")))
|
(message (one-or-more (zero-or-more not-newline) (? "\r") "\n")))
|
||||||
"FLYCHECK_END" (? "\r") line-end)
|
"FLYCHECK_END" (? "\r") line-end)
|
||||||
(warning line-start "FLYCHECK_BEGIN WARNING" (? "\r") "\n"
|
(warning line-start "FLYCHECK_BEGIN WARNING" (? "\r") "\n"
|
||||||
(file-name) ":" line ":" (? column ":") " warning "
|
(file-name) ":" line ":" (? column ":") " warning: "
|
||||||
(minimal-match
|
(minimal-match
|
||||||
(message (one-or-more (one-or-more not-newline) (? "\r") "\n")))
|
(message (one-or-more (zero-or-more not-newline) (? "\r") "\n")))
|
||||||
"FLYCHECK_END" (? "\r") line-end))
|
"FLYCHECK_END" (? "\r") line-end))
|
||||||
:modes (lean-mode)))
|
:modes (lean-mode)))
|
||||||
(add-to-list 'flycheck-checkers 'lean-checker))
|
(add-to-list 'flycheck-checkers 'lean-checker))
|
||||||
|
@ -79,7 +69,7 @@
|
||||||
(after lean-flycheck-try-parse-error-with-pattern activate)
|
(after lean-flycheck-try-parse-error-with-pattern activate)
|
||||||
"Add 1 to error-column."
|
"Add 1 to error-column."
|
||||||
(let* ((err ad-return-value)
|
(let* ((err ad-return-value)
|
||||||
(col (flycheck-error-column err)))
|
(col (and err (flycheck-error-column err))))
|
||||||
(when (and (string= major-mode "lean-mode") col)
|
(when (and (string= major-mode "lean-mode") col)
|
||||||
(setf (flycheck-error-column ad-return-value) (1+ col))))))
|
(setf (flycheck-error-column ad-return-value) (1+ col))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue