可以在系统的临时目录中创建flymake的临时文件吗? [英] Can flymake's temporary file be created in the system's temporary directory?

查看:186
本文介绍了可以在系统的临时目录中创建flymake的临时文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码来连接emacs中的flymake和Pyflakes:

I am currently using the following code to hook up flymake and Pyflakes in emacs:

(defun flymake-create-temp-in-system-tempdir (filename prefix)
  (make-temp-file (or prefix "flymake")))

然后我将此函数传递给 flymake-init-create-temp-buffer-copy 。 (取自 http://hustoknow.blogspot。 com / 2010/09 / emacs-and-pyflakes-using-tmp-directory.html )。

and then I pass this function to flymake-init-create-temp-buffer-copy. (Taken from http://hustoknow.blogspot.com/2010/09/emacs-and-pyflakes-using-tmp-directory.html).

此代码一直运行到昨天。当我访问某些Python文件时,我会收到以下错误:

This code worked fine until yesterday. When I visit certain Python files, I get the following error:

switched OFF Flymake mode for buffer admin.py due to fatal status
CFGERR, warning Configuration error has occured while running    
(pyflakes ../../../../../../../tmp/flymake28459SVv)

为什么flymake将错误的文件名传递给pyflakes?我希望它通过像/ tmp / efe234234这样的东西,我没有修改任何tmp目录设置。

Why is flymake passing what seems like the wrong filename to pyflakes? I expect it to pass something like "/tmp/efe234234" and I haven't modified any of the tmp directory settings.

我不记得正在更新的emacs Ubuntu最近不能想到任何可能导致这种情况的事情(.emacs文件被版本化)。

I don't recall emacs being updated for Ubuntu recently and can't think of anything that might have caused this to mess up (.emacs files are versioned).

我可以想到的唯一的问题是这个是一个大量嵌套的目录,符号链接到我的〜/ Dropbox目录中的目录,但这并不像其他符号链接那样发生。

The only issue I can think of is that this is a heavily nested directory symlinked to a directory in my ~/Dropbox directory but this doesn't happen to other symlinked in a similar way.

我如何解决这个问题?

更新

我做了一些调试,现在我看到它不是通过正确的路径作为参数。它需要一个更多的父目录插入路径使其工作,这使我认为它被弄乱了因为符号链接。

I've done some debugging and now I see that it's not passing the correct path as the argument. It needs one more parent directory inserted into the path to make it work which makes me think it's getting messed up because of symlinks.

这是一个示例shell会话来显示什么我的意思是。我从正确的相对目录中执行此操作:

Here is an example shell session to show what I mean. I am doing this from the correct relative directory:

$ pyflakes ../../../../../tmp/flymake13382xHi 
../../../../../tmp/flymake13382xHi: No such file or directory

这是flymake正在尝试运行的命令。如果我更改:

That is the command flymake is trying to run. If I change it:

$ pyflakes ../../../../../../tmp/flymake13382xHi

我没有输出(如预期)。请注意路径中的额外..。

I get no output (as expected). Note the extra ".." in the path.

如何让flymake通过绝对路径而不是这些疯狂的相对路径?

How can I get flymake to pass an absolute path instead of these crazy relative paths?

更新2

我已经完成了所有工作。基本上有这个功能:

I've gotten everything to work. Basically there is this function:

(defun flymake-pyflakes-init ()
     ; Make sure it's not a remote buffer or flymake would not work
     (when (not (subsetp (list (current-buffer)) (tramp-list-remote-buffers)))
      (let* ((temp-file (flymake-init-create-temp-buffer-copy
                    'flymake-create-temp-in-system-tempdir))
             (local-file (file-relative-name
                      temp-file
                      (file-name-directory buffer-file-name))))
    (list "pyflakes" (list temp-file)))))

在最后一部分我不得不将参数更改为列表本地文件 temp-file ,因为本地文件是我没有的疯狂的相对路径想。为什么该片段的作者首先使用 local-file

In the last part I had to change the argument to list from local-file to temp-file because local-file was the crazy relative path I didn't want. Why did the author of that snippet use local-file in the first place?

谢谢
Ryan

Thanks, Ryan

推荐答案

对于我来说,我已经通过修改用户脚本/ usr / local / bin / pyflakes来解决,我测试如果文件存在如果没有,我添加一个斜杠。

For me, i have resolved by modify user script /usr/local/bin/pyflakes, i test if file exist, if no, i add a slash.

#!/bin/bash

FILE=$1

# Test if folder exist
if [ ! -e "$FILE" ]; then
FILE="/$1"
fi

epylint "$FILE" 2>/dev/null
pep8 --ignore=E221,E701,E202 --repeat "$FILE"
true

这篇关于可以在系统的临时目录中创建flymake的临时文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆