苍蝇和Python

2024-06-01 08:37:25 发布

您现在位置:Python中文网/ 问答频道 /正文

当我调用py execute region(绑定到C-C |)时,我从flymake get file name模式得到了一个错误,并屏蔽了“无效文件名”。还会出现名为/tmp/python-3434.py的void buffer。在

我的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允许的文件名掩码” '(“\.py\”flymake pylint init))) (添加hook‘python mode hook’flymake模式)


Tags: namepyexecuteinit文件名localbuffercreate
1条回答
网友
1楼 · 发布于 2024-06-01 08:37:25

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

相关问题 更多 >