diff options
author | Barry Warsaw <barry@python.org> | 1996-03-06 18:41:38 (GMT) |
---|---|---|
committer | Barry Warsaw <barry@python.org> | 1996-03-06 18:41:38 (GMT) |
commit | 6d627754c1aa94b0aebb8aa055ee496960a5802f (patch) | |
tree | 599c2b833502d5d716b61d925dc1a1f062be7c65 | |
parent | 378815ca860871b4cfeed65ce31e0099fdb6c92c (diff) | |
download | cpython-6d627754c1aa94b0aebb8aa055ee496960a5802f.zip cpython-6d627754c1aa94b0aebb8aa055ee496960a5802f.tar.gz cpython-6d627754c1aa94b0aebb8aa055ee496960a5802f.tar.bz2 |
(py-honor-comment-indentation, py-compute-indentation): allow other
than nil or t values.
-rw-r--r-- | Misc/python-mode.el | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el index 19e675f..1b00296 100644 --- a/Misc/python-mode.el +++ b/Misc/python-mode.el @@ -100,15 +100,20 @@ should be of the form `#x...' where `x' is not a blank or a tab, and `...' is arbitrary).") (defvar py-honor-comment-indentation t - "*If non-nil, single-# comments are a hint to subsequent line indentation. -If the previous line is a comment which begins with a single `#' -character (as opposed to `py-block-comment-prefix' -- normally `##'), -then it's indentation is used as a hint for this line's indentation. -When this variable is nil, all comments are skipped for indentation -purposes, and a faster algorithm is used. + "*Controls how comment lines influence subsequent indentation. -Under Emacs 18, or old Emacs 19's, this variable has no effect, and -the behavior is as if it were always non-nil.") +When nil, all comment lines are skipped for indentation purposes, and +in Emacs 19, a faster algorithm is used. + +When t, lines that begin with a single `#' are a hint to subsequent +line indentation. If the previous line is such a comment line (as +opposed to one that starts with `py-block-comment-prefix'), then it's +indentation is used as a hint for this line's indentation. Lines that +begin with `py-block-comment-prefix' are ignored for indentation +purposes. + +When not nil or t, comment lines that begin with a `#' are used as +indentation hints, unless the comment character is in column zero.") (defvar py-scroll-process-buffer t "*Scroll Python process buffer as output arrives. @@ -864,10 +869,18 @@ the new line indented." ;; will skip a blank or non-indenting comment line that ;; happens to be a continuation line too. use fast Emacs 19 ;; function if it's there. - (if (and (not py-honor-comment-indentation) + (if (and (eq py-honor-comment-indentation nil) (fboundp 'forward-comment)) (forward-comment (- (point-max))) - (re-search-backward "^[ \t]*\\([^ \t\n#]\\|#[ \t\n]\\)" nil 'move)) + (let (done) + (while (not done) + (re-search-backward "^[ \t]*\\([^ \t\n#]\\|#[ \t\n]\\)" + nil 'move) + (setq done (or (eq py-honor-comment-indentation t) + (bobp) + (/= (following-char) ?#) + (not (zerop (current-column))))) + ))) ;; if we landed inside a string, go to the beginning of that ;; string. this handles triple quoted, multi-line spanning ;; strings. |