- Subject: Re: how to indent a region multiple times in python-mode
- From: "G. Milde" <g.milde@xxxxxx>
- Date: Mon, 18 Sep 2006 12:34:56 +0200
On 16.09.06, Jörg Sommer wrote:
> Hello Joachim,
>
> Joachim Schmitz <js@xxxxxxxxxxxxx> wrote:
> > in python-mode I can indent a region for one tab, how to shift the
> > region multiple tabs ?
>
> Try this patch:
Thanks for this patch. I found one problem, though: Multiple unindent could
accidentially delete code:
> define py_shift_line_left()
> {
> + variable times = prefix_argument(1);
> bol_skip_white();
- if (what_column() > Py_Indent_Level) {
+ if (what_column() > times * Py_Indent_Level) {
> push_mark();
> - goto_column(what_column() - Py_Indent_Level);
> + goto_column(what_column() - times * Py_Indent_Level);
> del_region();
> }
> }
As the attempt to unindent more that there is indentation could lead to ugly
surprises (especially if unnoticed in a py_shift_region_left() operation, I
changed the code to:
define py_shift_line_left()
{
variable times = prefix_argument(1);
bol_skip_white();
if (what_column() < times * Py_Indent_Level)
verror("Line is less than %d columns indented", times * Py_Indent_Level);
push_mark();
goto_column(what_column() - times * Py_Indent_Level);
del_region();
}
This way the user is warned that something unintented happended and can look
into the problem.
Günter
--------------------------
To unsubscribe send email to <jed-users-request@xxxxxxxxxxx> with
the word "unsubscribe" in the message body.
Need help? Email <jed-users-owner@xxxxxxxxxxx>.
[2006 date index]
[2006 thread index]
[Thread Prev] [Thread Next]
[Date Prev] [Date Next]