summaryrefslogtreecommitdiffstats
path: root/Misc
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1995-09-14 18:49:11 (GMT)
committerBarry Warsaw <barry@python.org>1995-09-14 18:49:11 (GMT)
commitc01c5c859cf3dda270979fd023a2989488f1894b (patch)
treecc5319d21b869937468ea1929df707ed4c2a88c2 /Misc
parente77438cce039276f7ddec324058ddd392059a11b (diff)
downloadcpython-c01c5c859cf3dda270979fd023a2989488f1894b.zip
cpython-c01c5c859cf3dda270979fd023a2989488f1894b.tar.gz
cpython-c01c5c859cf3dda270979fd023a2989488f1894b.tar.bz2
(py-compute-indentation): when inside a comment, indent to under the
most previous non-blank line.
Diffstat (limited to 'Misc')
-rw-r--r--Misc/python-mode.el14
1 files changed, 14 insertions, 0 deletions
diff --git a/Misc/python-mode.el b/Misc/python-mode.el
index 2ec8f95..eb94759 100644
--- a/Misc/python-mode.el
+++ b/Misc/python-mode.el
@@ -784,6 +784,20 @@ the new line indented."
(save-excursion
(beginning-of-line)
(cond
+ ;; are we inside a string or comment?
+ ((save-excursion
+ (let ((pps (parse-partial-sexp (save-excursion
+ (beginning-of-python-def-or-class)
+ (point))
+ (point))))
+ (or (nth 3 pps) (nth 4 pps))))
+ (save-excursion
+ ;; 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)
+ (back-to-indentation)
+ (current-column)))
;; are we on a continuation line?
((py-continuation-line-p)
(let ((startpos (point))