(py-continuation-offset): New variable which controls how much to

indent continuation lines, defined as lines following those that end
in backslash.

(py-compute-indentation): Support for py-continuation-offset.
This commit is contained in:
Barry Warsaw 2001-06-18 23:40:35 +00:00
parent 3eec38af37
commit fd4c9e87a7
1 changed files with 12 additions and 3 deletions

View File

@ -8,7 +8,7 @@
;; Created: Feb 1992 ;; Created: Feb 1992
;; Keywords: python languages oop ;; Keywords: python languages oop
(defconst py-version "$Revision$" (defconst py-version "4.1"
"`python-mode' version number.") "`python-mode' version number.")
;; This software is provided as-is, without express or implied ;; This software is provided as-is, without express or implied
@ -123,6 +123,13 @@ you're editing someone else's Python code."
:type 'integer :type 'integer
:group 'python) :group 'python)
(defcustom py-continuation-offset 4
"*Additional amount of offset to give for continuation lines.
Continuation lines are those that immediately follow a backslash
terminated line."
:type 'integer
:group 'python)
(defcustom py-smart-indentation t (defcustom py-smart-indentation t
"*Should `python-mode' try to automagically set some indentation variables? "*Should `python-mode' try to automagically set some indentation variables?
When this variable is non-nil, two things happen when a buffer is set When this variable is non-nil, two things happen when a buffer is set
@ -1800,7 +1807,8 @@ dedenting."
;; chunk of non-whitespace characters on base line, + 1 more ;; chunk of non-whitespace characters on base line, + 1 more
;; column ;; column
(end-of-line) (end-of-line)
(setq endpos (point) searching t) (setq endpos (point)
searching t)
(back-to-indentation) (back-to-indentation)
(setq startpos (point)) (setq startpos (point))
;; look at all "=" from left to right, stopping at first ;; look at all "=" from left to right, stopping at first
@ -1825,7 +1833,8 @@ dedenting."
(progn (progn
(goto-char startpos) (goto-char startpos)
(skip-chars-forward "^ \t\n"))) (skip-chars-forward "^ \t\n")))
(1+ (current-column)))))) (+ (current-column) py-continuation-offset 1)
))))
;; not on a continuation line ;; not on a continuation line
((bobp) (current-indentation)) ((bobp) (current-indentation))