paetzke / py-autopep8.el

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

go--apply-rcs-patch is void #1

Closed Airead closed 11 years ago

Airead commented 11 years ago

when I run python-fmt, I get errors:

Wrote /tmp/autopep825173kvD.py
if: Symbol's function definition is void: go--apply-rcs-patch

and what should I do?

paetzke commented 11 years ago

Hi, I uploaded a new version. Give it a try.

Airead commented 11 years ago

Thank you for py-autopep8!

I have tested it, but it didn't work. test code:

import sys

def hello(num):
    print num

the above code have warning:

E302 expected 2 blank lines, found 1

after I run python-fmt, nothing changes in the buffer. :( Beause I can't find how to patch a buffer with another diff buffer, so I instead (go--apply-rcs-patch patchbuf) with:

    (setq lineno (line-number-at-pos))
    (erase-buffer)
    (insert-file tmpfile)
    (goto-line lineno)

Maybe it's not the best solution, but it works. :)

paetzke commented 11 years ago

Yeah, I didn't supplied the necessary function. Try the current version.

Airead commented 11 years ago

tested, but it's still not perfect... test code:

import sys

def hello(num):
    print num

(note: blank line)

above code have warning:

W391 blank line at end of file

autopep8 will fix it, but python-fmt do nothing. :(

paetzke commented 11 years ago

how do you call autopep8? I've tried it, but it doesn't remove the blank lines. (autopep8 0.9.2)

Airead commented 11 years ago

autopep8 version is different.

airead@AIREAD:/tmp/test$ autopep8 --version
autopep8 0.9.2
airead@AIREAD:/tmp/test$ cat t.py
import sys

def hello(num):
    print num

airead@AIREAD:/tmp/test$ autopep8 t.py 
import sys

def hello(num):
    print num
airead@AIREAD:/tmp/test$ 
paetzke commented 11 years ago

hm, that seems to be a problem with the before-save-hook. If I open the file with the blank line and save it the hook doesn't get called. If I make a chance in that file, the hook is called and the blank line is removed. If I open the file with the blank lines and call python-fmt (M-x python-fmt) directly the lines are also removed.

Airead commented 11 years ago

I bind C-c f to python-fmt, when I call python-fmt I got

Wrote /tmp/autopep823214tpJ.py
save-current-buffer: Symbol's function definition is void: go--kill-whole-line

the go--kill-whole-line doesn't exist....

And I go to eat dinner

paetzke commented 11 years ago

Replaced it with kill-whole-line in current version

Airead commented 11 years ago

works, perfect now!

paetzke commented 11 years ago

Glad to hear.