Display Flycheck buffer (with errors) when saving

2019-07-15 08:23发布

In Emacs, what would be the way to display the Flycheck buffer automatically when saving, only if there are errors?

A bit like https://github.com/steelbrain/linter.

I've searched on https://stackoverflow.com/questions/tagged/flycheck?sort=votes&pageSize=50 but did not find anything approaching.

1条回答
Emotional °昔
2楼-- · 2019-07-15 08:35

Add the following to ~/.emacs, this will bind it to C-x C-s:

(defun save-buffer-maybe-show-errors ()
  "Save buffer and show errors if any."
  (interactive)
  (save-buffer)
  (when (not flycheck-current-errors)
    (flycheck-list-errors)))
;; Bind it to some key:
(global-set-key (kbd "C-x C-s") 'save-buffer-maybe-show-errors)
查看更多
登录 后发表回答