paetzke / py-autopep8.el

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

Avoid altering the kill ring #15

Closed paul-english closed 8 years ago

paul-english commented 8 years ago

Running py-autopep8 will alter the kill-ring leading to some unexpected side effects (for example, if buffers are set to autosave). It makes it confusing to copy a piece of text, move to another buffer and try to paste if py-autopep8 has run in-between.

This is a bit of a naive quick fix, that simply pops the kill-ring when a kill command is issued. I think the proper way would be to use delete-region to replace kill-whole-line and kill-buffer usage, but my elisp is rusty and I don't know the equivalents off-hand.

This also affects py-yapf and py-isort, but I won't submit any changes unless you think the current change is sufficient or if something like delete-region would be cleaner.

paetzke commented 8 years ago

Thank you for your patch!

csboling commented 8 years ago

I believe the issue is that killing in the sense of kill-buffer means to close a buffer, which does not affect the kill ring like kill-whole-line does. Removing (pop kill-ring) after each occurrence of kill-buffer seems to behave, pull request here.