From 9f1537ef3e5e6782edacfacbf9f4396e3ab11bd1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fabi=C3=A1n=20Ezequiel=20Gallina?= Date: Thu, 17 May 2012 00:03:08 -0300 Subject: [PATCH] Added indentation support for continuation of dotted expressions Expressions like these are now supported and indented correctly: Object.objects.exclude(foo=1)\ .filter(bar=2)\ .values_list('baz') Also added a small fix to python-info-assignment-continuation-line-p to check the match for the operator is not inside some paren. --- lisp/progmodes/python.el | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 79ef752c0f2..b745050f551 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -618,6 +618,17 @@ START is the buffer position where the sexp starts." (save-excursion (forward-line -1) (python-info-assignment-continuation-line-p))) + (dot-continuation + (save-excursion + (back-to-indentation) + (when (looking-at "\\.") + (forward-line -1) + (back-to-indentation) + (forward-char (length + (with-syntax-table python-dotty-syntax-table + (current-word)))) + (re-search-backward "\\." (line-beginning-position) t 1) + (current-column)))) (indentation (cond (block-continuation (goto-char block-continuation) (re-search-forward @@ -634,6 +645,8 @@ START is the buffer position where the sexp starts." (python-rx (* space)) (line-end-position) t) (current-column)) + (dot-continuation + dot-continuation) (t (goto-char context-start) (current-indentation))))) @@ -1956,6 +1969,7 @@ not inside a defun." not-simple-operator) (line-end-position) t) (not (or (python-info-ppss-context 'string) + (python-info-ppss-context 'paren) (python-info-ppss-context 'comment)))))) (point-marker)))) -- 2.39.5