I have searched the googlewebs, but I have been unable to find an emacs package that will automatically break long lines in a (Python) language conforming way. For example:

def _formatDependencyList(usedList):
if len(usedList) == 0:
return '(This thing does not use modules)'
return ', '.join([_escapeUnderscores(_getBaseNameHead(s)) for s in usedList])

The s in the rightmost occurrence of usedList is in column 80 in my file, and having gotten to the end of the line, I would like to issue a command, much like the M-q/fill-paragraph command, to 'fix' this one line and make it look like this:

In this special case the ( and the [ that follow join are adjacent, so I would break the line after [. (In the more typical case, I would break the line at the first ( or [ character.)

This seems to me like something that emacs could do, and probably does (somewhere), and it would save me a whole lotta keystrokes. Honestly, I do not know how people use editors that cannot fill paragraphs, and if I had this too I would likewise be unable to continue living without it.

This is not about filling paragraphs, but automated code formatting, a surprisingly hard problem. You'll have more success finding an external program doing this, then running it over your code.
– wasamasaMar 3 '16 at 17:25

2

Pep8ify is a great program to do this for python. By default though it does not do long lines, you need to toggle the long line flag when you run it.
– JulesMar 3 '16 at 21:10