paetzke / py-autopep8.el

py-autopep8.el integrates autopep8 into Emacs.
GNU General Public License v3.0
79 stars 21 forks source link

avoiding ^M when using py-autopep8 on Windows #8

Closed benstroud closed 9 years ago

benstroud commented 10 years ago

Using py-autopep8 on Windows:

test.py (saved with DOS-style EOL, but same results when saving as UNIX EOL)


import os, os.path

Becomes the following after M-x py-autopep8:

^M
^M
import os^M
import os.path^M

Is there a way to avoid the extra ^M being added? When running autopep8 from cmdline I don't get the extra characters. Thanks

paetzke commented 10 years ago

Hi,

I tried to reproduce this by mixing the encodings in a single file but failed on Ubuntu. What is the encoding of your file?

benstroud commented 10 years ago

For the test I posted...

1 -- iso-latin-1-dos (alias: iso-8859-1-dos latin-1-dos)

ISO 2022 based 8-bit encoding for Latin-1 (MIME:ISO-8859-1).
Type: charset (charset)
EOL type: CRLF
This coding system encodes the following charsets:
  iso-8859-1

My mode line reads 1\---. Please let me know how to provide additional details if needed. Thanks.

ptracton commented 9 years ago

I am seeing the same thing. Using emacs-24.3.1 on Windows 7. It runs fine on Linux Mint 17, but not on Windows. If you need more information or want try out a fix, let me know.

paetzke commented 9 years ago

Could you try this? https://github.com/paetzke/py-autopep8.el/tree/fix-encoding

ptracton commented 9 years ago

Sorry for the delay. This did not appear to work. When I save I still get the ^M on the end of the line. A second save removes the end of line from each line making the code unreadable.

ptracton commented 9 years ago

A quick hack that looks better so far is to comment out coding-system-for-read and coding-system-for-write. The ^M goes away and the buffer gets fixed up. I do not know enough elisp to know the side effects from this.

paetzke commented 9 years ago

Removing the coding-systems works also for me, but not on travis:

https://travis-ci.org/paetzke/py-autopep8.el/builds/38704424

ptracton commented 9 years ago

What is the cassou PPA for emacs? How is this different from the default one? I am using the default one in Mint. I took that step out of test.bash and the test cases passed on my Linux Mint 17 PC.

Phil

On Wed, Oct 22, 2014 at 6:03 AM, Friedrich Paetzke <notifications@github.com

wrote:

Removing the coding-systems works also for me, but not on travis:

https://travis-ci.org/paetzke/py-autopep8.el/builds/38704424

— Reply to this email directly or view it on GitHub https://github.com/paetzke/py-autopep8.el/issues/8#issuecomment-60080797 .

paetzke commented 9 years ago

The PPA is just for Travis CI. The build server is an Ubuntu 12.04 with Emacs 23. From the PPA I install an Emacs 24. I modified the test.bash to add the PPA only on Travis.

MortalCatalyst commented 9 years ago

I have this on windows7 64 bit latest emacs 24 running emacs using https://github.com/purcell/emacs.d This was the only alteration to that default configuration.

paetzke commented 9 years ago

Could you try this branch? https://github.com/paetzke/py-autopep8.el/tree/fix-encoding

paetzke commented 9 years ago

Patch is merged