开发者

flymake and python-execute-region

I got an error from flymake-get-file-name-mode-and-masks "Invalid file name" when I have called py-execute-region (bind to C-c |). Also void buffer with name like /tmp/python-3434.py appears.

My flymake setup:

(when (load "flymake" t)
 (defun flymake-pylint-init ()
 (let* ((temp-file (flymake-init-create-temp-buffer-copy
                    'flymake-create-temp-inplace))
        (local-file (file-relative-name
                     temp-file
                     (file-name-directory buffer-file-name))))
   (list "epylint" (lis开发者_StackOverflow中文版t local-file))))

(add-to-list 'flymake-allowed-file-name-masks '("\.py\'" flymake-pylint-init))) (add-hook 'python-mode-hook 'flymake-mode)


I had this same problem, and solved it by making emacs not load flymake for temporary buffers passed to the interpreter. I

The relevant bits of my flymake setup for Python:

(when (load "flymake" t)
  (defun flymake-python-init ()
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
                     'flymake-create-temp-inplace))
         (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list "pyflymake" (list local-file)))) ; substitute epylint for this
  (push '(".+\\.py$" flymake-python-init) flymake-allowed-file-name-masks))

(add-hook 'python-mode-hook
          (lambda ()
            ; Activate flymake unless buffer is a tmp buffer for the interpreter
            (unless (eq buffer-file-name nil) (flymake-mode t)) ; this should fix your problem
            ;; Bind a few keys for navigating errors
            (local-set-key (kbd "C-c w") 'show-fly-err-at-point) ; remove these if you want
            (local-set-key (kbd "M-n") 'flymake-goto-next-error)
            (local-set-key (kbd "M-p") 'flymake-goto-prev-error)))
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜