From unknown Sun Jun 22 07:52:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12060: 24.1.50; python.el: Preserve position of point when indenting Resent-From: Lawrence Mitchell Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 Jul 2012 18:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 12060 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 12060@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.134332880917200 (code B ref -1); Thu, 26 Jul 2012 18:54:02 +0000 Received: (at submit) by debbugs.gnu.org; 26 Jul 2012 18:53:29 +0000 Received: from localhost ([127.0.0.1]:41480 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SuTBh-0004TN-6R for submit@debbugs.gnu.org; Thu, 26 Jul 2012 14:53:29 -0400 Received: from eggs.gnu.org ([208.118.235.92]:49241) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1SuTBe-0004TE-SY for submit@debbugs.gnu.org; Thu, 26 Jul 2012 14:53:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SuT4u-0000UI-Qo for submit@debbugs.gnu.org; Thu, 26 Jul 2012 14:46:34 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, FSL_RCVD_USER,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.2 Received: from lists.gnu.org ([208.118.235.17]:47517) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuT4u-0000UC-Nc for submit@debbugs.gnu.org; Thu, 26 Jul 2012 14:46:28 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuT4q-0000vO-Rp for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 14:46:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SuT4k-0000Pf-Np for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 14:46:24 -0400 Received: from nougat.ucs.ed.ac.uk ([129.215.13.205]:64877) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuT4k-0000JN-Eq for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 14:46:18 -0400 Received: from lmtp1.ucs.ed.ac.uk (lmtp1.ucs.ed.ac.uk [129.215.149.64]) by nougat.ucs.ed.ac.uk (8.13.8/8.13.4) with ESMTP id q6QIjtru011278 for ; Thu, 26 Jul 2012 19:46:00 +0100 (BST) Received: from e4300lm (cpc11-sgyl30-2-0-cust962.sgyl.cable.virginmedia.com [94.175.87.195]) (authenticated user=lmitche4 mech=PLAIN bits=0) by lmtp1.ucs.ed.ac.uk (8.13.8/8.13.7) with ESMTP id q6QIjjMs022076 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NOT) for ; Thu, 26 Jul 2012 19:45:54 +0100 (BST) From: Lawrence Mitchell Date: Thu, 26 Jul 2012 19:45:44 +0100 Message-ID: <87d33il5t3.fsf@ed.ac.uk> MIME-Version: 1.0 Content-Type: text/plain X-Edinburgh-Scanned: at nougat.ucs.ed.ac.uk with MIMEDefang 2.60, Sophie, Sophos Anti-Virus, Clam AntiVirus X-Scanned-By: MIMEDefang 2.60 on 129.215.13.205 X-Scanned-By: MIMEDefang 2.52 on 129.215.149.64 X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 208.118.235.17 X-Spam-Score: -6.9 (------) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.9 (------) The new version of python.el has somewhat surprising (at least to me) indenting behaviour. When indenting, point is moved from the current position on the line to the first non-whitespace character. This is unlike most other progmodes which preserve the relative position of point in the line when indenting and only move to the first non-whitespace character when point is in whitespace at the beginning of the line. Here's a patch + changelog entry to introduce the normal behaviour: python: Preserve relative position of point when indenting * lisp/progmodes/python.el (python-indent-line): Restore point if we weren't in whitespace at the beginning of the line. diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el index 132951a..224d0ae 100644 --- a/lisp/progmodes/python.el +++ b/lisp/progmodes/python.el @@ -862,17 +862,20 @@ possible indentation levels and saves it in the variable `python-indent-levels'. Afterwards it sets the variable `python-indent-current-level' correctly so offset is equal to (`nth' `python-indent-current-level' `python-indent-levels')" - (if (or (and (eq this-command 'indent-for-tab-command) - (eq last-command this-command)) - force-toggle) - (if (not (equal python-indent-levels '(0))) - (python-indent-toggle-levels) - (python-indent-calculate-levels)) - (python-indent-calculate-levels)) - (beginning-of-line) - (delete-horizontal-space) - (indent-to (nth python-indent-current-level python-indent-levels)) - (python-info-closing-block-message)) + (let ((pos (- (point-max) (point)))) + (if (or (and (eq this-command 'indent-for-tab-command) + (eq last-command this-command)) + force-toggle) + (if (not (equal python-indent-levels '(0))) + (python-indent-toggle-levels) + (python-indent-calculate-levels)) + (python-indent-calculate-levels)) + (beginning-of-line) + (delete-horizontal-space) + (indent-to (nth python-indent-current-level python-indent-levels)) + (if (> (- (point-max) pos) (point)) + (goto-char (- (point-max) pos))) + (python-info-closing-block-message))) (defun python-indent-line-function () "`indent-line-function' for Python mode. In GNU Emacs 24.1.50.2 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10) of 2012-07-07 on e4300lm Windowing system distributor `The X.Org Foundation', version 11.0.11103000 Configured using: `configure '--prefix=/home/lmitche4/Apps/emacs' '-C' 'CFLAGS=-O0 -ggdb3'' From unknown Sun Jun 22 07:52:26 2025 X-Loop: help-debbugs@gnu.org Subject: bug#12060: 24.1.50; python.el: Preserve position of point when indenting References: <87d33il5t3.fsf@ed.ac.uk> In-Reply-To: <87d33il5t3.fsf@ed.ac.uk> Resent-From: =?UTF-8?Q?Fabi=C3=A1n?= Ezequiel Gallina Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 24 Sep 2012 18:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12060 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 12060@debbugs.gnu.org Received: via spool by 12060-submit@debbugs.gnu.org id=B12060.134851081024629 (code B ref 12060); Mon, 24 Sep 2012 18:21:01 +0000 Received: (at 12060) by debbugs.gnu.org; 24 Sep 2012 18:20:10 +0000 Received: from localhost ([127.0.0.1]:53516 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TGDGL-0006PC-R7 for submit@debbugs.gnu.org; Mon, 24 Sep 2012 14:20:10 -0400 Received: from mail-gg0-f172.google.com ([209.85.161.172]:55577) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TGDGK-0006P5-61 for 12060@debbugs.gnu.org; Mon, 24 Sep 2012 14:20:09 -0400 Received: by ggnh4 with SMTP id h4so1819134ggn.3 for <12060@debbugs.gnu.org>; Mon, 24 Sep 2012 11:18:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding:x-gm-message-state; bh=sneXALLokDvLNJxS3gM2dUtOheIxZ9RFFD2o3S8aSVA=; b=iI7VIPJWaPdz0iesIM3vpWT2Atkw7JyEhbZWvSlcqoVvxbQW+PipqrocUCSdO9gwQe wUKuZ2Gw64vio+TrDKncEbxXjwp4x9fu+fJhVcOoTAR7rl4CSvXdYEnBGLmkfgdw7dMr tucCkwwxXZyVAU+9unccqbqVXP5JoYb5laDA0prpRyOBG4QpRrt0rfH7+FuPlxEaSFUn hZ/IbFWhFeEK2Q1rO7/GvDJ4spix2q5ORw4YPMX7n/53WHMZhKz4OYU7leuQzx3xOZ4x oNaoCkpKgR1xbwBWKl0JRZq9AcmK/sYY+t6m1o0nfjQhLZnh/UL8abZ7sY9GUP0TBeKz x/rQ== Received: by 10.236.151.99 with SMTP id a63mr13287805yhk.120.1348510692360; Mon, 24 Sep 2012 11:18:12 -0700 (PDT) Received: from [192.168.1.25] (host71.190-138-197.telecom.net.ar. [190.138.197.71]) by mx.google.com with ESMTPS id t20sm17163090anl.19.2012.09.24.11.18.10 (version=SSLv3 cipher=OTHER); Mon, 24 Sep 2012 11:18:11 -0700 (PDT) Message-ID: <5060A3F7.5070600@anue.biz> Date: Mon, 24 Sep 2012 15:18:31 -0300 From: =?UTF-8?Q?Fabi=C3=A1n?= Ezequiel Gallina User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120910 Thunderbird/15.0.1 MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQn4629vqK1IWA2YBmNi/aghtGmniv+8gFtavKde0wAYXEzhyjy0aZxhw3cIZVXxHhw6IXIK X-Spam-Score: -2.6 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) A fix for this has been committed in revno 110170. From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 24 14:20:55 2012 Received: (at control) by debbugs.gnu.org; 24 Sep 2012 18:20:55 +0000 Received: from localhost ([127.0.0.1]:53519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TGDH5-0006Q7-7f for submit@debbugs.gnu.org; Mon, 24 Sep 2012 14:20:55 -0400 Received: from mail-gh0-f172.google.com ([209.85.160.172]:37620) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TGDH3-0006Q1-Pb for control@debbugs.gnu.org; Mon, 24 Sep 2012 14:20:54 -0400 Received: by ghbg10 with SMTP id g10so1855972ghb.3 for ; Mon, 24 Sep 2012 11:18:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:content-type :content-transfer-encoding:x-gm-message-state; bh=/KwJeT7rvHxkmxNclwGtFG27UMyhpczl4Ti1w9mRxOI=; b=g3EMNyTlOr0ga195ArPuJWbXM3uO8qVNA9H5MI+WLe4Ugp++vp6yq/DGe00QZaV0Bf omdY2dZ8qGzcxi9o53K26AF2Y1p/v26nH13DC+i7YSENcaZb6HaaurLXngmhqpIVHct8 rvYa9ktlc2r/MblQCOlBmejQBDsGhxbzpwi0a2Iz7aB0h0jzlzUbsaKpHbh7SiRek7Kt oua3Wxad3/3PM17GVEMUIQvcWyYSmDc+VxlA3MgEE6dGwBarxJqniw+0J5AEIAiHhJDB WkY6YyxRZ2D4A50ajS/eLTRvMQGBsD9znA3IIMLUKFEAcOEjbTc9uD5xGaMWCDJVFbMv Gmfw== Received: by 10.236.9.36 with SMTP id 24mr13251326yhs.63.1348510738410; Mon, 24 Sep 2012 11:18:58 -0700 (PDT) Received: from [192.168.1.25] (host71.190-138-197.telecom.net.ar. [190.138.197.71]) by mx.google.com with ESMTPS id m51sm25823640yhh.16.2012.09.24.11.18.56 (version=SSLv3 cipher=OTHER); Mon, 24 Sep 2012 11:18:57 -0700 (PDT) Message-ID: <5060A425.1090600@anue.biz> Date: Mon, 24 Sep 2012 15:19:17 -0300 From: =?ISO-8859-1?Q?Fabi=E1n_Ezequiel_Gallina?= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120910 Thunderbird/15.0.1 MIME-Version: 1.0 To: control@debbugs.gnu.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQnJXzsLBD1818bzM1HRBXc41IAao2XpV3dI3Ks3Y6D4tv1hR3LYyJ+ha+V2h/IlOPvmR9OL X-Spam-Score: 2.2 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: close #12060 [...] Content analysis details: (2.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 3.0 GOT_NO_SUBJECT No real subject -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.172 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.8 MISSING_SUBJECT Missing Subject: header X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: 2.2 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has identified this incoming email as possible spam. The original message has been attached to this so you can view it (if it isn't spam) or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: close #12060 [...] Content analysis details: (2.2 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.160.172 listed in list.dnswl.org] 3.0 GOT_NO_SUBJECT No real subject -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 1.8 MISSING_SUBJECT Missing Subject: header 0.0 TVD_SPACE_RATIO TVD_SPACE_RATIO close #12060