Set python indent to 2 spaces in emacs 23?

前端 未结 3 837
名媛妹妹
名媛妹妹 2021-02-05 07:12

I am using emacs 23.1.1 on Ubuntu 10.04. I wish to program in Python with a 2-space indent. emacs looks to have a default mode for python (python.el?).

I put the follow

3条回答
  •  清歌不尽
    2021-02-05 07:39

    I just ran into this problem myself, and I think the help for python-indent contains a big clue that no one else mentioned:

    See also `M-x python-guess-indent'
    

    If you don't customize python-guess-indent by setting it to nil, then python.el will automatically set python-indent for each Python buffer (that contains indented text), making your python-indent customization ineffective. (On the other hand, when in Rome...)

    In the end, this is what went into my .emacs file (ignoring all other custom variables):

    (custom-set-variables
     '(python-guess-indent nil)
     '(python-indent 2))
    

提交回复
热议问题