summaryrefslogtreecommitdiff
path: root/elisp/pylint.el
blob: 753c679acba4c9a8a97572771a8ebf9a8821d0f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37

;; adapted from pychecker for pylint
(defun pylint-python-hook ()
  (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)))
	   (command (concat "pylint --output-format=parseable \"" file "\"")))
      (save-some-buffers (not compilation-ask-about-save) nil) ; save  files.
      (compile-internal command "No more errors or warnings" "pylint")))
;;  (local-set-key [f1] 'pylint)
;;  (local-set-key [f2] 'previous-error)
;;  (local-set-key [f3] 'next-error)

  (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))

  )

(add-hook 'python-mode-hook 'pylint-python-hook)