diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index e4019373362..3cdfb43e35f 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -568,7 +568,12 @@ START is the buffer position where the sexp starts." (save-excursion (goto-char context-start) (forward-char) - (if (looking-at "[[:space:]]*$") + (save-restriction + (narrow-to-region + (line-beginning-position) + (line-end-position)) + (forward-comment 1)) + (if (looking-at "$") (+ (current-indentation) python-indent-offset) (forward-comment 1) (current-column)))