41 lines
1.3 KiB
EmacsLisp
41 lines
1.3 KiB
EmacsLisp
(defun flymake-create-copy-file ()
|
|
"Create a copy local file"
|
|
(let* ((temp-file (flymake-init-create-temp-buffer-copy
|
|
'flymake-create-temp-inplace)))
|
|
(file-relative-name
|
|
temp-file
|
|
(file-name-directory buffer-file-name))))
|
|
|
|
(defun flymake-command-parse (cmdline)
|
|
"Parses the command line CMDLINE in a format compatible
|
|
with flymake, as:(list cmd-name arg-list)
|
|
|
|
The CMDLINE should be something like:
|
|
|
|
flymake %f python custom.py %f
|
|
|
|
%f will be substituted with a temporary copy of the file that is
|
|
currently being checked.
|
|
"
|
|
(let ((cmdline-subst (replace-regexp-in-string "%f" (flymake-create-copy-file) cmdline)))
|
|
(setq cmdline-subst (split-string-and-unquote cmdline-subst))
|
|
(list (first cmdline-subst) (rest cmdline-subst))
|
|
))
|
|
|
|
(when (load-file (concat user-extensions-directory "flymake/flymake-patch.el"))
|
|
(setq flymake-info-line-regex
|
|
(append flymake-info-line-regex '("unused$" "^redefinition" "used$")))
|
|
(load-library "flymake-cursor"))
|
|
|
|
(defun epy-setup-checker (cmdline)
|
|
(add-to-list 'flymake-allowed-file-name-masks
|
|
(list "\\.py\\'" (apply-partially 'flymake-command-parse cmdline)))
|
|
)
|
|
(epy-setup-checker "pyflakes %f")
|
|
|
|
(eval-after-load 'python
|
|
'(progn
|
|
(add-hook 'python-mode-hook (lambda () (if (buffer-file-name)
|
|
(flymake-mode))))
|
|
)
|
|
)
|