gpt4 book ai didi

python - flymake 和 python-execute-region

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:43 25 4
gpt4 key购买 nike

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

我的 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com