paetzke / py-autopep8.el Goto Github PK
View Code? Open in Web Editor NEWpy-autopep8.el integrates autopep8 into Emacs.
License: GNU General Public License v3.0
py-autopep8.el integrates autopep8 into Emacs.
License: GNU General Public License v3.0
No matter what I try setting the py-autopep8-options variable to, I either get 1 of 2 outcomes. Either I do something along the lines of (setq py-autopep8-options '("-a"))
and get an aggresssiveness level lower than I want or do something along the lines of (setq py-autopep8-options '("-a -a))
and get an error. Is this an issue with my understanding of the py-autopep8-options variable?
I installed autopep8 two weeks ago and I'm plagued by autopep8 removing valid code from my scripts. I use docopt and nipype, which have unique syntax but I'm stumped. Here's an example of code that is auto-removed:
#!/usr/bin/env python
# emacs: -*- mode: python; py-indent-offset: 4; indent-tabs-mode: nil -*-
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""
Usage:
preprocessing.py [-h | --help]
preprocessing.py [-f | --force] [-g | -b] [-F FORMAT | --format=FORMAT] (-n NAME| --name=NAME) SESSION...
Arguments:
-n NAME, --name=NAME experiment name
SESSION one or more session IDs
Optional:
-h, --help show this help message and exit
-f, --force force DataSink rewriting
-g global signal regression by masking gray matter
-b whole brain
-F FORMAT, --format=FORMAT output format, values: afni, nifti, nifti_gz [default: nifti]
Example:
preprocessing.py -n my_new_experiment 0001 0002 0003
preprocessing.py -fgF nifti_gz --name new_experiment_w_gray_mask 00001 00002 00003
preprocessing.py -bn my_new_experiment_brain_mask --format afni 0001 0002 0003
"""
# TODO: Modify virtualenv to include formatFMRI.sh
import os
import sys
import SEMTools as sem
from nipype.interfaces.ants.registration import Registration
from nipype.interfaces.ants import ApplyTransforms
from nipype.interfaces.afni.preprocess import *
from nipype.interfaces.freesurfer.preprocess import *
from nipype.interfaces.io import DataSink, DataGrabber
from nipype.interfaces.utility import Function, IdentityInterface, Rename, Select
from nipype.interfaces.utility import Merge as Merger
import nipype.pipeline.engine as pipe
import numpy
from utilities import *
...
Removing the #emacs ...
and #vi:...
lines stops this behavior, but I can't reproduce it now. It appears randomly!?! >:(
When editing other people's code, I would like to disable the hook on a per buffer basis so I don't change their whitespace or other aspects of their code.
Are you open to a change like this in py-autopep8.el?
;;;###autoload
(defun py-autopep8-enable-on-save ()
"Pre-save hook to be used before running autopep8."
(interactive)
(if current-prefix-arg
(progn
(remove-hook 'before-save-hook 'py-autopep8-buffer t)
(message "py-autopep8-buffer removed"))
(add-hook 'before-save-hook 'py-autopep8-buffer nil t)))
I can create a pull request if so, otherwise, I am open to your preferences...
Thanks
It's work well at emacs24.4 (GNU Emacs 24.4.1 (x86_64-apple-darwin13.4.0))
but
when I use Emacs of Mac OS X(This is GNU Emacs 24.5.1 (x86_64-apple-darwin13.4.0, NS apple-appkit-1265.21),with GUI, display "autopep8 command not found" on the mini buffer.
also,
I use this M-x py-autopep8-buffer to call the function.
thanks.
After invoking M-x py-autopep8-buffer
, the intermediate, temporary file is created Wrote /tmp/autopep80Mlf6X.py
. Immediately afterwards, the error kill-append: Args out of range: 0, 0
is raised.
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
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?
Hi,
So first of all, thanks for this useful package.
I forked this repo and started making some changes.
Namely I refactored so that it is a minor-mode than can be enabled/disabled on a per-buffer basis.
I'd like to know if you think I should drop the PR here or if I should push my own package to MELPA ?
But there does not seem to have many activity around here...
Cheers
Hello!
Please, add code for automatic calling docformatter after calling autopep8. Author of autopep8 recommend using this tool for better python docs formatting.
In the CMD, I can call autopep8. But in the emacs it can't be called by this tool.
Modified ~/.emacs to include
(require 'py-autopep8.el)
(add-hook 'python-mode-hook 'py-autopep8-enable-on-save)
After saving, a number of elements have been removed from the kill ring.
code in use is
I know this is not py-autopep8 issue, but it is really annoying. Imagine you have a file (f.e one w/ huge dict definition) which effectively kills autopep8 (or make it really busy for couple minutes). While this is happening, the whole is editor is frozen and can't be worked with. Could this issue be solved async processing?
It's super annoying especially when you have autopep8 on save hook on.
There is an error when I try to execute py-autopep8-before-save
on Python mode buffer:
Invalid function: decf
Emacs version is: GNU Emacs 24.3.1
And py-autopep8 version is: 20140528.1138
What information could I provide to help resolve this?
I'd like to be able to disable autopep8 by default, and enable on a per-repository basis.
I have the following:
~/.config/pep8:
[pep8]
select=None
$PROJECT/setup.cfg
[pep8]
select=
When I run autopep8 $PROJECT/bad.py
, this behaves as I expect, and bad.py
is printed with errors corrected. Furthermore, if I remove setup.cfg
, autopep8
will respect the user config and will no longer correct errors.
However, if I open up bad.py
with emacs, py-autopep8
reports the buffer as already pep8ified, as if setup.cfg
wasn't there. (py-autopep8
works fine if I edit the user config, but that's not the behavior I want).
Have you considered adding the package to Melpa?
It would be handy to install py-autopep8.el through package.el.
Thanks,
Lukas
Hey,
For some reason, when compiling my .emacs no matter what I try, I always get this error on the line containing (require 'py-autopep8)
Any thoughts?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.