Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can flymake's temporary file be created in the system's temporary directory?

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

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

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)

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.

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

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.

How can I fix this problem?

UPDATE

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.

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

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.

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

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

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?

Thanks, Ryan

like image 715
Ryan Kaskel Avatar asked Nov 14 '22 00:11

Ryan Kaskel


1 Answers

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
like image 189
Bruno Adelé Avatar answered Dec 25 '22 13:12

Bruno Adelé