Question

I'm trying to use flymake to run pyflakes, as suggested here

This works fine for local files, and almost works with remote files with a bit of tweaking, but I'm left with a problem where flymake/pyflakes 'modifies' the buffer when it runs (although nothing actually seems to change), which renders it a bit useless in practice (e.g. saving a file runs flymake which immediately modifies the buffer again).

Here's what I did to almost get it working:

  1. Installed pyflakes on the remote box.
  2. Customized my tramp-remote-process-environment variable so that pyflakes could be found in its PATH
  3. Used a variant of the code from the wiki link above. Obviously I excluded the check that disables it for remote buffers. Also, the (when (load "flymake" t) ...) construct didn't seem to work as I expected, but I'm not too worried about that.
  4. Re-defined (for test purposes -- advice should be fine if this can be made to work) the flymake-start-syntax-check-process function so that it uses start-file-process (which works with tramp) instead of start-process (which does not).

The change in #4 does not appear to cause any issues when processing a local file, but although this now enables flymake to run the remote pyflakes for the remote files (errors are highlighted as expected), in this instance the buffer is 'modified' whenever flymake runs.

I'm guessing that start-file-process, for remote processes, results in some additional return value/data that does not occur for local processes.

Does anyone have any insight/advice?

  • Emacs 23.1 and 23.2 on Ubuntu
  • Python 2.4.6
  • Pyflakes 0.4.0 (via easy_install)
Was it helpful?

Solution

You need to tell flymake to create it's copy of the buffer somewhere locally, I prefer using the $TMP directory since this also allows me to use tramp on files in directories I don't have write permissions to.

You may want to checkout my fork of flymake-python since it does all this.

OTHER TIPS

I have this fixed in my fork of Flymake (https://github.com/illusori/emacs-flymake).

It will either run the syntax check on the remote machine via Tramp, without the buffer-modification issue you're seeing; or you can set flymake-run-in-place to nil and it will run the syntax check on the local machine, just like flymake on a regular non-Tramp buffer.

Since it's fixed at the Flymake level, this fix works for all languages and syntax checks rather than just pyflakes.

If you're interested in details of why it's happening, basically when the Tramp handler for start-file-process kicks in, it dumps the login message for the connection onto the end of the current buffer before any output filter can be attached to the process.

Usually this manifests as people seeing the contents of /etc/issue appear at the end of their file along with "You have mail." and so on.

In your case it may be that the login message is empty or just a new-line, so you're not seeing any text being added, even though it's setting the buffer as being modified.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top