unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "Fabián Ezequiel Gallina" <fabian@anue.biz>
Cc: 13888@debbugs.gnu.org
Subject: bug#13888: patch for python indentation
Date: Sun, 17 Mar 2013 18:25:04 -0400	[thread overview]
Message-ID: <jwvzjy11x8u.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <878v61kniv.fsf@gmail.com> (Aaron Ecay's message of "Wed, 06 Mar 2013 02:14:48 -0500")

> 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





  reply	other threads:[~2013-03-17 22:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-06  7:14 bug#13888: patch for python indentation Aaron Ecay
2013-03-17 22:25 ` Stefan Monnier [this message]
2013-03-26  2:10 ` bug#13888: Fabian Ezequiel Gallina

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvzjy11x8u.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=13888@debbugs.gnu.org \
    --cc=fabian@anue.biz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).