当我调用py-execute-region(绑定到C-c |)时,我从flymake-get-file-name-mode-and-masks“无效的文件名”中得到了一个错误。还会出现名称为/tmp/python-3434.py的void缓冲区。

我的flymake设置:

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


(添加到列表'flymake-allowed-file-name-masks
                '(“ \ .py \'” flymake-pylint-init)))
   (add-hook'python-mode-hook'flymake-mode)

最佳答案

我遇到了同样的问题,并通过使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)))

关于python - flymake和python-execute-region,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/2681203/

10-11 21:04