From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lawrence Mitchell Newsgroups: gmane.emacs.bugs Subject: bug#12060: 24.1.50; python.el: Preserve position of point when indenting Date: Thu, 26 Jul 2012 19:45:44 +0100 Message-ID: <87d33il5t3.fsf@ed.ac.uk> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1343328438 11450 80.91.229.3 (26 Jul 2012 18:47:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 26 Jul 2012 18:47:18 +0000 (UTC) To: 12060@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Jul 26 20:47:16 2012 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 1SuT5f-00072V-38 for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Jul 2012 20:47:15 +0200 Original-Received: from localhost ([::1]:39978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuT5e-0002BF-D1 for geb-bug-gnu-emacs@m.gmane.org; Thu, 26 Jul 2012 14:47:14 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:60080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuT5b-0002As-Jl for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 14:47:12 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SuT5a-0000d7-KF for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 14:47:11 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:60167) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SuT5a-0000d1-GX for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 14:47:10 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1SuTCE-0004U9-9n for bug-gnu-emacs@gnu.org; Thu, 26 Jul 2012 14:54:02 -0400 X-Loop: help-debbugs@gnu.org 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: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.134332880917200 (code B ref -1); Thu, 26 Jul 2012 18:54:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 26 Jul 2012 18:53:29 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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) Original-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) 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-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 (newer, 2) 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:62432 Archived-At: 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''