--Don
(defvar py-nested-indent t
"*If non-nil, indent nested continuation lines to inside the opening paren")
(defun py-compute-indentation ()
(save-excursion
(beginning-of-line)
(cond
;; are we on a continuation line?
( (py-continuation-line-p)
(let ((nest (and py-nested-indent (py-nesting-level))))
(if nest
(save-excursion
(goto-char nest)
(beginning-of-line)
(1+ (- nest (point))))
(forward-line -1)
(if (py-continuation-line-p) ; on at least 3rd line in block
(current-indentation) ; so just continue the pattern
;; else on 2nd line in block, so indent more
(+ (current-indentation) py-indent-offset
py-continuation-offset)))))
;; not on a continuation line
;; if at start of restriction, or on a non-indenting comment line,
;; assume they intended whatever's there
( (or (bobp) (looking-at "[ \t]*#[^ \t\n]"))
(current-indentation) )
;; else indentation based on that of the statement that precedes
;; us; use the first line of that statement to establish the base,
;; in case the user forced a non-std indentation for the
;; continuation lines (if any)
( t
;; skip back over blank & non-indenting comment lines
;; note: will skip a blank or non-indenting comment line that
;; happens to be a continuation line too
(re-search-backward "^[ \t]*\\([^ \t\n#]\\|#[ \t\n]\\)"
nil 'move)
(py-goto-initial-line)
(if (py-statement-opens-block-p)
(+ (current-indentation) py-indent-offset)
(current-indentation))))))
______ ______
\_\_\_\ /#/#/#/
\_\_\_\ ______
\_\_\_V#/#/#/ Donald Beaudry don@vicorp.com
\_\_/#/#/#/ V. I. Corporation uunet!vicorp!don
\_/#/#/#/ 47 Pleasant Street PHONE: (413) 586-4144
V#/#/#/ Northampton, MA 01060 FAX: (413) 586-3805