GNU bug report logs - #2421
23.0.90; python-mode: Indent commands behavior

Previous Next

Package: emacs;

Reported by: Milan Zamazal <pdm <at> zamazal.org>

Date: Sat, 21 Feb 2009 10:30:05 UTC

Severity: wishlist

Done: Fabián Ezequiel Gallina <fabian <at> anue.biz>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Milan Zamazal <pdm <at> zamazal.org>
To: martin rudalics <rudalics <at> gmx.at>
Cc: 2421 <at> debbugs.gnu.org
Subject: bug#2421: 23.0.90; python-mode: Indent commands behavior
Date: Mon, 23 Feb 2009 19:25:28 +0100
[Message part 1 (text/plain, inline)]
>>>>> "mr" == martin rudalics <rudalics <at> gmx.at> 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  <pdm <at> zamazal.org>

	* 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.

[python.el.patch (text/x-diff, inline)]
--- 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.
[Message part 3 (text/plain, inline)]
Regards,

Milan Zamazal

This bug report was last modified 12 years and 232 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.