emacs 中的 Python 代码检查器包装器无法正确地将结果提供给 win32 上的 Flymake
所以我使用 emacs python wiki 上建议的这个包装器(在这里找到)围绕 pep8、pyflakes 和 pylint,它们在命令行上工作(在根据“在 Windows 中使用子进程运行 Python 代码检查器包装器。来自 emacswiki 产生相同的错误”。
但是,在 emacs 中,flymake 会在有错误的行下划线,但是当我将鼠标悬停时,应包含错误消息的框是空的。我的init 文件包含:
(setq pycodechecker "etcwrapper.bat")
(when (load "flymake" t)
(load-library "flymake-cursor")
(defun dss/flymake-pycodecheck-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 pycodechecker (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" dss/flymake-pycodecheck-init)))
etcwrapper.bat 是一个简单的批处理脚本,它在 python 包装器脚本上运行 python,为了方便起见,我将其放在系统路径的目录中。 另外,我可以让 Flymake 仅在一个字符而不是整行下划线吗? 有什么建议吗?
So i'm using this wrapper suggested on the emacs python wiki (found here) around pep8, pyflakes and pylint which works on the command line (after the trouble of getting it setup on windows according to " Running python scripts with subprocess in windows. Python code checker wrappers from the emacswiki yield the same error ".
However, in emacs, flymake will underline the line having an error but when I hover the mouse, the box that should contain the error message is empty. My init file contains:
(setq pycodechecker "etcwrapper.bat")
(when (load "flymake" t)
(load-library "flymake-cursor")
(defun dss/flymake-pycodecheck-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 pycodechecker (list local-file))))
(add-to-list 'flymake-allowed-file-name-masks
'("\\.py\\'" dss/flymake-pycodecheck-init)))
etcwraper.bat is a simple batch script that runs python on the python wrapper script. I put it in a directory in my system path for convenience.
Also can I make flymake underline only one character rather than the whole line?
Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不是 python 专家,也从未在 Windows 上使用过它,所以这个答案可能没有用......但我知道某些版本的
flymake-cursor
中有一个 hack 来应对事实上,pyflakes
要么没有正确报告编译错误,要么它们的格式不适合flymake
解析。您可以在我的
flymake-cursor
分支中看到尝试修复它:https://github.com/illusori/emacs-flymake-cursor/blob/master/flymake-cursor.el#L126
我从 Dino Chiesa 版本中得到了这个修复,所以我不我不知道完整的背景故事,但听起来这就是您遇到的问题。
更新版本的
flymake-cursor
(例如我的或 Dino 的)可能会帮助您在 emacs 消息区域中看到错误指示器,但鼠标覆盖是在flymake
中处理的,它具有据我所知,这个问题还没有修复。如果您提供 etcwrapper.bat 手动运行时生成的输出,我也许可以提供进一步的帮助。
仅在一个字符下划线也很棘手,根据我的理解,您需要从
flymake.el
重新定义flymake-make-overlay
并创建两个覆盖层而不是一个。您可能会发现将flymake-errline
和flymake-warnline
的外观自定义为比下划线更少干扰的内容更容易。抱歉,这些答案都不是解决办法。 :)
I'm not a python expert, and have never used it on windows, so this answer may not be useful... but I know there's a hack in some versions of
flymake-cursor
to cope with the fact thatpyflakes
either doesn't report errors correctly for compile errors, or that they're in the wrong format forflymake
to parse.You can see the attempted fix for it in my fork of
flymake-cursor
here:https://github.com/illusori/emacs-flymake-cursor/blob/master/flymake-cursor.el#L126
I got that fix from the Dino Chiesa version, so I don't know the full backstory, but it sounds like that's the issue you're having.
A more recent version of
flymake-cursor
such as mine or Dino's may help you see an error indicator in the emacs message area, but the mouse overlay is handled inflymake
which has no fixes for this issue as far as I'm aware.If you provide the output generated by your etcwrapper.bat when run manually, I might be able to help further.
Underlining just one character is also tricky, from my understanding you'd need to redefine
flymake-make-overlay
fromflymake.el
and create two overlays instead of one. You may just find it easier to customize the face forflymake-errline
andflymake-warnline
to something less intrusive than underline.Sorry that neither of these answers are a fix. :)