Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I get Emacs' indent-region command to re-indent

def foo():
    my_favorite_object_ever = ObjectConstructor(cool_parameter=4, not_cool_parameter=5)

as

def foo():
    my_favorite_object_ever = ObjectConstructor(cool_parameter=4,
                                                not_cool_parameter=5)

when I'm working in Python mode?

Is there a way I can perhaps combine fill-region and indent-region?

EDIT:

So far I've got this Elisp code in my .emacs:

(defun fill-indent-region (begin end)
  "Fill and then indent the code from BEGIN to END."
  (interactive "r")
  (save-restriction
    (narrow-to-region begin end)
    (fill-region (point-min) (point-max))
    (indent-region (point-min) (point-max))))

It is a little buggy though.

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.