2007-07-13 11:28:40 +00:00
|
|
|
(require 'compile)
|
2006-04-26 10:48:09 +00:00
|
|
|
|
|
|
|
;; adapted from pychecker for pylint
|
2007-07-04 12:06:21 +00:00
|
|
|
(defun pylint-python-hook ()
|
2006-04-26 10:48:09 +00:00
|
|
|
(defun pylint ()
|
|
|
|
"Run pylint against the file behind the current buffer after
|
|
|
|
checking if unsaved buffers should be saved."
|
|
|
|
|
|
|
|
(interactive)
|
|
|
|
(let* ((file (buffer-file-name (current-buffer)))
|
2006-08-10 13:53:58 +00:00
|
|
|
(command (concat "pylint --output-format=parseable \"" file "\"")))
|
2006-04-26 10:48:09 +00:00
|
|
|
(save-some-buffers (not compilation-ask-about-save) nil) ; save files.
|
|
|
|
(compile-internal command "No more errors or warnings" "pylint")))
|
2007-07-04 12:06:21 +00:00
|
|
|
;; (local-set-key [f1] 'pylint)
|
|
|
|
;; (local-set-key [f2] 'previous-error)
|
|
|
|
;; (local-set-key [f3] 'next-error)
|
2006-04-26 10:48:09 +00:00
|
|
|
|
|
|
|
(define-key
|
|
|
|
py-mode-map
|
|
|
|
[menu-bar Python pylint-separator]
|
|
|
|
'("--" . pylint-seperator))
|
|
|
|
|
|
|
|
(define-key
|
|
|
|
py-mode-map
|
|
|
|
[menu-bar Python next-error]
|
|
|
|
'("Next error" . next-error))
|
|
|
|
(define-key
|
|
|
|
py-mode-map
|
|
|
|
[menu-bar Python prev-error]
|
|
|
|
'("Previous error" . previous-error))
|
|
|
|
(define-key
|
|
|
|
py-mode-map
|
|
|
|
[menu-bar Python lint]
|
|
|
|
'("Pylint" . pylint))
|
|
|
|
|
|
|
|
)
|
|
|
|
|
2007-07-04 12:06:21 +00:00
|
|
|
(add-hook 'python-mode-hook 'pylint-python-hook)
|