unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13888: patch for python indentation
@ 2013-03-06  7:14 Aaron Ecay
  2013-03-17 22:25 ` Stefan Monnier
  2013-03-26  2:10 ` bug#13888: Fabian Ezequiel Gallina
  0 siblings, 2 replies; 3+ messages in thread
From: Aaron Ecay @ 2013-03-06  7:14 UTC (permalink / raw)
  To: 13888

[-- Attachment #1: Type: text/plain, Size: 214 bytes --]

A previous version of emacs’ python-mode would unindent the line after a
pass or retrun keyword, which end the current block.  The current
version does not do so.  The attached patch restores this behavior.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Improve-python-indentation-after-return-or-pass.patch --]
[-- Type: text/x-patch, Size: 1977 bytes --]

From f695ce5ade65d3be0c34ec74443bb65f8cfa688b Mon Sep 17 00:00:00 2001
From: Aaron Ecay <aaronecay@gmail.com>
Date: Wed, 6 Mar 2013 01:33:48 -0500
Subject: [PATCH] Improve python indentation after return or pass

* progmodes/python.el (python-indent-calculate-indentation): Unindent
after a return or pass keyword on the previous line.
---
 lisp/ChangeLog           |  5 +++++
 lisp/progmodes/python.el | 12 +++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 88b9992..1cd9dc2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,8 @@
+2013-03-06  Aaron Ecay  <aaronecay@gmail.com>
+
+	* progmodes/python.el (python-indent-calculate-indentation):
+	Unindent after a return or pass keyword on the previous line.
+
 2013-03-05  Michael Albinus  <michael.albinus@gmx.de>
 
 	* net/tramp-compat.el (tramp-compat-delete-directory): Implement
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index f0f67d0..6102490 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -763,9 +763,15 @@ START is the buffer position where the sexp starts."
             (save-excursion
               (goto-char context-start)
               (current-indentation))
-            (if (progn
-                  (back-to-indentation)
-                  (looking-at (regexp-opt python-indent-dedenters)))
+            (if (or (progn
+                      (back-to-indentation)
+                      (looking-at (regexp-opt python-indent-dedenters)))
+                    (progn
+                      (back-to-indentation)
+                      (skip-chars-backward (rx (or whitespace ?\n)))
+                      (back-to-indentation)
+                      (looking-at (rx (or "pass" "return")
+                                      (or " " "\n")))))
                 python-indent-offset
               0)))
           ;; When inside of a string, do nothing. just use the current
-- 
1.8.1.5


[-- Attachment #3: Type: text/plain, Size: 16 bytes --]


-- 
Aaron Ecay

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#13888: patch for python indentation
  2013-03-06  7:14 bug#13888: patch for python indentation Aaron Ecay
@ 2013-03-17 22:25 ` Stefan Monnier
  2013-03-26  2:10 ` bug#13888: Fabian Ezequiel Gallina
  1 sibling, 0 replies; 3+ messages in thread
From: Stefan Monnier @ 2013-03-17 22:25 UTC (permalink / raw)
  To: Fabián Ezequiel Gallina; +Cc: 13888

> A previous version of emacs’ python-mode would unindent the line after a
> pass or retrun keyword, which end the current block.  The current
> version does not do so.  The attached patch restores this behavior.

Fabián, podrías mirar eso, por favor?


        Stefan


>> From f695ce5ade65d3be0c34ec74443bb65f8cfa688b Mon Sep 17 00:00:00 2001
> From: Aaron Ecay <aaronecay@gmail.com>
> Date: Wed, 6 Mar 2013 01:33:48 -0500
> Subject: [PATCH] Improve python indentation after return or pass

> * progmodes/python.el (python-indent-calculate-indentation): Unindent
> after a return or pass keyword on the previous line.
> ---
>  lisp/ChangeLog           |  5 +++++
>  lisp/progmodes/python.el | 12 +++++++++---
>  2 files changed, 14 insertions(+), 3 deletions(-)

> diff --git a/lisp/ChangeLog b/lisp/ChangeLog
> index 88b9992..1cd9dc2 100644
> --- a/lisp/ChangeLog
> +++ b/lisp/ChangeLog
> @@ -1,3 +1,8 @@
> +2013-03-06  Aaron Ecay  <aaronecay@gmail.com>
> +
> +	* progmodes/python.el (python-indent-calculate-indentation):
> +	Unindent after a return or pass keyword on the previous line.
> +
>  2013-03-05  Michael Albinus  <michael.albinus@gmx.de>
 
>  	* net/tramp-compat.el (tramp-compat-delete-directory): Implement
> diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
> index f0f67d0..6102490 100644
> --- a/lisp/progmodes/python.el
> +++ b/lisp/progmodes/python.el
> @@ -763,9 +763,15 @@ START is the buffer position where the sexp starts."
>              (save-excursion
>                (goto-char context-start)
>                (current-indentation))
> -            (if (progn
> -                  (back-to-indentation)
> -                  (looking-at (regexp-opt python-indent-dedenters)))
> +            (if (or (progn
> +                      (back-to-indentation)
> +                      (looking-at (regexp-opt python-indent-dedenters)))
> +                    (progn
> +                      (back-to-indentation)
> +                      (skip-chars-backward (rx (or whitespace ?\n)))
> +                      (back-to-indentation)
> +                      (looking-at (rx (or "pass" "return")
> +                                      (or " " "\n")))))
>                  python-indent-offset
>                0)))
>            ;; When inside of a string, do nothing. just use the current
> -- 
> 1.8.1.5



> -- 
> Aaron Ecay





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#13888:
  2013-03-06  7:14 bug#13888: patch for python indentation Aaron Ecay
  2013-03-17 22:25 ` Stefan Monnier
@ 2013-03-26  2:10 ` Fabian Ezequiel Gallina
  1 sibling, 0 replies; 3+ messages in thread
From: Fabian Ezequiel Gallina @ 2013-03-26  2:10 UTC (permalink / raw)
  To: 13888

I just pushed a fix for this in revno 111338.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-03-26  2:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-06  7:14 bug#13888: patch for python indentation Aaron Ecay
2013-03-17 22:25 ` Stefan Monnier
2013-03-26  2:10 ` bug#13888: Fabian Ezequiel Gallina

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).