views:

59

answers:

1

Im an emacs newbie, I want emacs to be able to indent my code like this

egg = spam.foooooo('vivivivivivivivivi')\
          .foooooo('emacs', 'emacs', 'emacs', 'emacs')

It's not possible to do this automatically by default (without manually inserting spaces or C-c >), since emacs always indents 4 spaces (unless Im splitting multiple arguments over multiple lines).

Whats the best approach to do this?

PS: If this is a bad idea (against PEP 8 or something) please do tell me

+1  A: 

That's pretty ugly and would require you to write some emacs lisp. I need to learn emacs lisp so if it wasn't so ugly, I would probably be up for doing it. But it is and I'm not. Looks like you get to learn emacs lisp :) (if you actually want to do this). I'm sort of jealous. At any rate, you said that informing you that this is a bad idea was an acceptable answer so here goes:

That's a terrible stylistic choice. Isn't

egg = spam.foo('viviviv')
egg = egg.foo('emacs', 'emacs', 'emacs')

easier to read?

While not specifically against PEP 8, it is mentioned that use of the line continuation character should be kept to a minimum. Also, this most definitively and objectively goes against the spirit of PEP 8. I'm just not sure how ;)

aaronasterling
I agree thats terribly stylistic :). Your suggestion already crossed my mind too. Looks like I have to update my question to inquire more opinion about styling
kusut
forget it. substance over style. I'll follow your answer if I want to follow PEP 8
kusut