From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Aaron Ecay Newsgroups: gmane.emacs.bugs Subject: bug#13888: patch for python indentation Date: Wed, 06 Mar 2013 02:14:48 -0500 Message-ID: <878v61kniv.fsf@gmail.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1362554146 24526 80.91.229.3 (6 Mar 2013 07:15:46 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 6 Mar 2013 07:15:46 +0000 (UTC) To: 13888@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Mar 06 08:16:10 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UD8a9-0005Rw-R8 for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Mar 2013 08:16:10 +0100 Original-Received: from localhost ([::1]:46707 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UD8Zo-0005Kc-5X for geb-bug-gnu-emacs@m.gmane.org; Wed, 06 Mar 2013 02:15:48 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:55058) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UD8Zg-0005KW-KI for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 02:15:41 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UD8Zf-0007lE-44 for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 02:15:40 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:57626) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UD8Zf-0007l8-1D for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 02:15:39 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UD8a2-000538-Om for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 02:16:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Aaron Ecay Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 06 Mar 2013 07:16:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13888 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.136255412819366 (code B ref -1); Wed, 06 Mar 2013 07:16:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 6 Mar 2013 07:15:28 +0000 Original-Received: from localhost ([127.0.0.1]:33502 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UD8ZT-00052J-JQ for submit@debbugs.gnu.org; Wed, 06 Mar 2013 02:15:28 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:43525) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UD8ZQ-000520-6w for submit@debbugs.gnu.org; Wed, 06 Mar 2013 02:15:25 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UD8Yv-0006vU-7a for submit@debbugs.gnu.org; Wed, 06 Mar 2013 02:14:54 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:56278) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UD8Yv-0006vN-53 for submit@debbugs.gnu.org; Wed, 06 Mar 2013 02:14:53 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:54867) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UD8Yt-0005DJ-Ni for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 02:14:53 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UD8Ys-0006rz-Ad for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 02:14:51 -0500 Original-Received: from mail-qe0-f53.google.com ([209.85.128.53]:57951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UD8Ys-0006rl-60 for bug-gnu-emacs@gnu.org; Wed, 06 Mar 2013 02:14:50 -0500 Original-Received: by mail-qe0-f53.google.com with SMTP id cz11so5112580qeb.40 for ; Tue, 05 Mar 2013 23:14:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:subject:user-agent:date:message-id:mime-version :content-type; bh=jMFP6OuMqzSb53Sk0yy1pbSRQ5aVmNF2kqXOvhye0Wg=; b=oIU7QlpoEShFZPnMWJ4rMGDyI5PZkgRrd70NuBSQMc3MX2Z/OaEYJmngkZp8EfVcAu HnHZHE4NiM+Gz3siV++pjw2Te5tboeQDXb4mDpXI5G5jn5eAxNhoMpTCe+QmfjgGJSju V3LBpt7lVEvxwRPiARDLeV0/g9z76vqG/3rkiBkeDkngTAcRUJaMwy3e7RBToEAmhrXb 3re4JYyFAWMlUiuKw8hx6htPCYIFmPb1nzZUnPn/2mwzfWDcO2uvGc/biO9TQU3Wj2OI Fm1UjGuAOXovgEIrz49MM8x9EpIvDoMA8tX/ZQBpr41HfE0GsugibRXlJud1ghihpbGv xbnQ== X-Received: by 10.224.179.133 with SMTP id bq5mr16169336qab.9.1362554089606; Tue, 05 Mar 2013 23:14:49 -0800 (PST) Original-Received: from localhost (c-68-80-94-73.hsd1.pa.comcast.net. [68.80.94.73]) by mx.google.com with ESMTPS id o5sm47283212qao.12.2013.03.05.23.14.48 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 05 Mar 2013 23:14:49 -0800 (PST) User-Agent: Notmuch/0.15.2+43~ge848af8 (http://notmuchmail.org) Emacs/24.3.50.1 (x86_64-unknown-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:72152 Archived-At: --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable A previous version of emacs=E2=80=99 python-mode would unindent the line af= ter a pass or retrun keyword, which end the current block. The current version does not do so. The attached patch restores this behavior. --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-Improve-python-indentation-after-return-or-pass.patch >From f695ce5ade65d3be0c34ec74443bb65f8cfa688b Mon Sep 17 00:00:00 2001 From: Aaron Ecay 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 + + * progmodes/python.el (python-indent-calculate-indentation): + Unindent after a return or pass keyword on the previous line. + 2013-03-05 Michael Albinus * 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 --=-=-= Content-Type: text/plain -- Aaron Ecay --=-=-=--