Editing Python in Emacs

I looked at python-mode and python.el. I am using python-mode.el. I also use rope and rosaki. I am looking for either some kind of documentation on these issues that helps me, or another elisp package or something else.

My current problem is that the code I have been given has inconsistent indent sizes. For some blocks, it will be two, for some it will be 4. I want to clear this, but for some reason, when I say emacs "correct indentation", it just clicks the tab on each line basically, which starts the code. I want to keep the same relative indent, but standardize to 4 spaces. Anything let me do this easily?

I assume that I can find each instance with a bad indentation, block it and request - replace 2 spaces with 4 spaces. But it depends too much on my accuracy, noticing where it should be done. Also, this is a lot of code.

Someone told me that a bicycle repairman will solve this, but it has not been development for several years ... Any other suggestions?

thank.

+5
source share
3 answers

Assuming you used Sven Marnach's comment to clear the code base, I assume that you just need to make python-mode.el use the indentation style that you prefer?

py-indent-offset py-smart-indentation (, , py-continuation-offset py-honor-comment-indentation). indent-tabs-mode.

(M-x customize-group RET python RET), python-mode-hook. :.

(add-hook 'python-mode-hook 'my-python-mode-hook)
(defun my-python-mode-hook ()
  (setq indent-tabs-mode nil
        py-smart-indentation nil
        py-indent-offset 4))
0

py-smart-indentation, `t '

python-mode.el .

http://launchpad.net/python-mode

0
(custom-set-variables
   ...
   '(indent-tabs-mode nil)
   '(tab-stop-list (quote (4 8 16 24 32 40 48 56 64 72 80 88 96 104 112 120)))
   '(tab-width 4))

Obviously, these are global settings for the modes that comply with them (which is what python-mode does). I have not succumbed to the indentation settings in python mode at all.

-1
source

All Articles