Does anyone have a modification to python-mode.el that implements something
along the lines of c-tab-always-indent? Currently, it a) gets the
indentation wrong inside of """ module strings; and b) reindents the line
if I try to use tabs inside subsequent lines of the """ comment string.

I can live with the first problem but not the second. With c/c++ my
solution is to set c-tab-always-indent to nil, which changes the behavior
so that it only reindents the line if the cursor is in the leading
whitespace, and otherwise it inserts a real tab (though a virtual tab is
fine, too).



Search Discussions

  • G.A. at Nov 11, 2003 at 6:55 pm
    On Mon, 10 Nov 2003 00:41:35 GMT, G.A. wrote:
    Rather than waiting around for an answer, I went ahead and made my
    modifications to python-mode.el. While I've tweaked emacs lisp stuff in
    the past, I've never been confidant about it, given the complexity of many
    elisp packages. So now the question is whether they're good enough to put
    back into the official version, and if so, how would I do that?

    For what it's worth, I'm including the code below. It's relatively small,
    a definition for py-tab-always-indent and a few lines changed in


    (defcustom py-tab-always-indent t
    "*Non-nil means TAB in Python mode should always reindent the current
    line, regardless of where in the line point is when the TAB command is
    :type 'boolean
    :group 'python)

    (defun py-indent-line (&optional arg)
    "Fix the indentation of the current line according to Python rules.
    With \\[universal-argument] (programmatically, the optional argument
    ARG non-nil), ignore dedenting rules for block closing statements
    (e.g. return, raise, break, continue, pass)

    This function is normally bound to `indent-line-function' so
    \\[indent-for-tab-command] will call it."
    (interactive "P")
    (let* ((ci (current-indentation))
    (move-to-indentation-p (<= (current-column) ci))
    (need (py-compute-indentation (not arg))))
    ;; see if we need to dedent
    (if (py-outdent-p)
    (setq need (- need py-indent-offset)))
    (if (or py-tab-always-indent
    (progn (if (/= ci need)
    (indent-to need)))
    (if move-to-indentation-p (back-to-indentation)))
  • Skip Montanaro at Nov 11, 2003 at 9:53 pm
    Gary> Rather than waiting around for an answer, I went ahead and made my
    Gary> modifications to python-mode.el.

    Can you submit your patch to the python-mode project on SF:





Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppython-list @
postedNov 10, '03 at 12:41a
activeNov 11, '03 at 9:53p

2 users in discussion

G.A.: 2 posts Skip Montanaro: 1 post



site design / logo © 2022 Grokbase