flymake和python-execute-region

时间:2010-04-21 08:03:20

标签: python emacs

当我调用py-execute-region(绑定到C-c |)时,我收到了来自flymake-get-file-name-mode-and-mask“无效文件名”的错误。此外,还会显示名为/tmp/python-3434.py的void缓冲区。

我的飞行设置:

(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" (list local-file))))

(add-to-list'flymake-allowed-file-name-masks                 '(“\。\”\“”flymake-pylint-init)))    (add-hook'python-mode-hook'flymake-mode)

1 个答案:

答案 0 :(得分:4)

我有同样的问题,并通过使emacs不加载flymake来传递给解释器的临时缓冲区来解决它。我

我的Python flymake设置的相关部分:

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