From: Milan Zamazal <pdm@zamazal.org>
To: martin rudalics <rudalics@gmx.at>
Cc: 2421@emacsbugs.donarmstrong.com
Subject: bug#2421: 23.0.90; python-mode: Indent commands behavior
Date: Mon, 23 Feb 2009 19:25:28 +0100 [thread overview]
Message-ID: <87y6vxvwmf.fsf@blackbird.nest.zamazal.org> (raw)
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")
[-- Attachment #1: Type: text/plain, Size: 1070 bytes --]
>>>>> "mr" == martin rudalics <rudalics@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@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.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: python.el.patch --]
[-- Type: text/x-diff, Size: 1747 bytes --]
--- 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.
[-- Attachment #3: Type: text/plain, Size: 25 bytes --]
Regards,
Milan Zamazal
next prev parent reply other threads:[~2009-02-23 18:25 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-02-21 10:25 bug#2421: 23.0.90; python-mode: Indent commands behavior Milan Zamazal
2009-02-21 14:10 ` martin rudalics
2009-02-21 14:59 ` Milan Zamazal
2009-02-22 18:29 ` martin rudalics
2009-02-23 18:25 ` Milan Zamazal [this message]
2009-02-24 13:40 ` martin rudalics
2009-02-24 14:58 ` Milan Zamazal
2009-03-04 16:42 ` Milan Zamazal
2009-03-05 18:58 ` martin rudalics
2009-03-06 8:24 ` Milan Zamazal
2012-10-08 21:43 ` Fabián Ezequiel Gallina
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87y6vxvwmf.fsf@blackbird.nest.zamazal.org \
--to=pdm@zamazal.org \
--cc=2421@emacsbugs.donarmstrong.com \
--cc=rudalics@gmx.at \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.