From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Milan Zamazal Newsgroups: gmane.emacs.bugs Subject: bug#2421: 23.0.90; python-mode: Indent commands behavior Date: Mon, 23 Feb 2009 19:25:28 +0100 Message-ID: <87y6vxvwmf.fsf@blackbird.nest.zamazal.org> References: <87k57k9je5.fsf@blackbird.nest.zamazal.org> <49A00B66.80908@gmx.at> <87ab8falaa.fsf@blackbird.nest.zamazal.org> <49A199A0.2030505@gmx.at> Reply-To: Milan Zamazal , 2421@emacsbugs.donarmstrong.com NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1236214534 6857 80.91.229.12 (5 Mar 2009 00:55:34 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 5 Mar 2009 00:55:34 +0000 (UTC) Cc: 2421@emacsbugs.donarmstrong.com To: martin rudalics Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Feb 23 19:46:48 2009 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Lbfp8-00059k-NG for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 Feb 2009 19:46:39 +0100 Original-Received: from localhost ([127.0.0.1]:39120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lbfno-0003p2-BT for geb-bug-gnu-emacs@m.gmane.org; Mon, 23 Feb 2009 13:45:16 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LbfmK-00039w-C9 for bug-gnu-emacs@gnu.org; Mon, 23 Feb 2009 13:43:44 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LbfmH-00037L-66 for bug-gnu-emacs@gnu.org; Mon, 23 Feb 2009 13:43:41 -0500 Original-Received: from [199.232.76.173] (port=56421 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LbfmG-000372-Ch for bug-gnu-emacs@gnu.org; Mon, 23 Feb 2009 13:43:40 -0500 Original-Received: from rzlab.ucr.edu ([138.23.92.77]:50420) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LbfmF-0002uC-BG for bug-gnu-emacs@gnu.org; Mon, 23 Feb 2009 13:43:39 -0500 Original-Received: from rzlab.ucr.edu (rzlab.ucr.edu [127.0.0.1]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n1NIhaSb002947; Mon, 23 Feb 2009 10:43:37 -0800 Original-Received: (from debbugs@localhost) by rzlab.ucr.edu (8.13.8/8.13.8/Submit) id n1NIZ4j2000738; Mon, 23 Feb 2009 10:35:04 -0800 X-Loop: owner@emacsbugs.donarmstrong.com Resent-From: Milan Zamazal Resent-To: bug-submit-list@donarmstrong.com Resent-CC: Emacs Bugs Resent-Date: Mon, 23 Feb 2009 18:35:04 +0000 Resent-Message-ID: Resent-Sender: owner@emacsbugs.donarmstrong.com X-Emacs-PR-Message: followup 2421 X-Emacs-PR-Package: emacs X-Emacs-PR-Keywords: Original-Received: via spool by 2421-submit@emacsbugs.donarmstrong.com id=B2421.123541353731742 (code B ref 2421); Mon, 23 Feb 2009 18:35:04 +0000 Original-Received: (at 2421) by emacsbugs.donarmstrong.com; 23 Feb 2009 18:25:37 +0000 X-Spam-Bayes: score:0.5 Bayes not run. spammytokens:Tokens not available. hammytokens:Tokens not available. Original-Received: from zamazal.org (ip51.strelice.net [217.66.176.51]) by rzlab.ucr.edu (8.13.8/8.13.8/Debian-3) with ESMTP id n1NIPYIw031736 for <2421@emacsbugs.donarmstrong.com>; Mon, 23 Feb 2009 10:25:35 -0800 Original-Received: from blackbird.nest.zamazal.org ([192.168.129.12]) by zamazal.org with esmtp (Exim 4.69) (envelope-from ) id 1LbfUj-0001lF-Fx; Mon, 23 Feb 2009 19:25:33 +0100 Original-Received: from pdm by blackbird.nest.zamazal.org with local (Exim 4.69) (envelope-from ) id 1LbfUe-0001lB-8n; Mon, 23 Feb 2009 19:25:28 +0100 In-Reply-To: <49A199A0.2030505@gmx.at> (sfid-20090223_013312_112480_3DB6D4EE) (martin rudalics's message of "Sun, 22 Feb 2009 19:29:52 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.90 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Resent-Date: Mon, 23 Feb 2009 13:43:41 -0500 X-BeenThere: bug-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:25997 --=-=-= >>>>> "mr" == martin rudalics writes: mr> I don't know whether `python-shift-left' and mr> `python-shift-right' are of any use without a prefix argument. They are, I often use them after adding or removing a statement in a code. mr> With a prefix argument, they are simple wrappers for mr> `indent-rigidly'. Yes, this makes no sense. It would be more logical if they indented by (* python-indent count). mr> Maybe you could propose a patch to provide the behavior you mr> like. OK, see below for some suggestion. mr> In any case, it might be better to use `use-region-p' instead of mr> `mark-active' to be more consistent with Emacs 23. But then the indent commands would work only if transient-mark-mode was enabled, wouldn't they? 2009-02-23 Milan Zamazal * python.el (python-shift-left, python-shift-right): When called with a prefix argument, indent by that many levels, not columns. * python.el (python-shift-left, python-shift-right): Don't deactivate the active mark. --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=python.el.patch --- python.el.orig 2009-02-23 19:06:19.000000000 +0100 +++ python.el 2009-02-23 19:18:37.000000000 +0100 @@ -2013,17 +2013,18 @@ (list (region-beginning) (region-end) current-prefix-arg) (list (line-beginning-position) (line-end-position) current-prefix-arg))) (if count - (setq count (prefix-numeric-value count)) + (setq count (* python-indent (prefix-numeric-value count))) (setq count python-indent)) - (when (> count 0) - (save-excursion - (goto-char start) - (while (< (point) end) - (if (and (< (current-indentation) count) - (not (looking-at "[ \t]*$"))) - (error "Can't shift all lines enough")) - (forward-line)) - (indent-rigidly start end (- count))))) + (let (deactivate-mark) + (when (> count 0) + (save-excursion + (goto-char start) + (while (< (point) end) + (if (and (< (current-indentation) count) + (not (looking-at "[ \t]*$"))) + (error "Can't shift all lines enough")) + (forward-line)) + (indent-rigidly start end (- count)))))) (add-to-list 'debug-ignored-errors "^Can't shift all lines enough") @@ -2036,10 +2037,11 @@ (if mark-active (list (region-beginning) (region-end) current-prefix-arg) (list (line-beginning-position) (line-end-position) current-prefix-arg))) - (if count - (setq count (prefix-numeric-value count)) - (setq count python-indent)) - (indent-rigidly start end count)) + (let (deactivate-mark) + (if count + (setq count (* python-indent (prefix-numeric-value count))) + (setq count python-indent)) + (indent-rigidly start end count))) (defun python-outline-level () "`outline-level' function for Python mode. --=-=-= Regards, Milan Zamazal --=-=-=--