unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* how to redo align-regexp?
@ 2016-10-05 17:02 HASM
  2016-10-05 17:45 ` Marco Wahl
  0 siblings, 1 reply; 9+ messages in thread
From: HASM @ 2016-10-05 17:02 UTC (permalink / raw)
  To: help-gnu-emacs


I mark a region and run align-regexp.

Then I mark a different region and attempt a repeat-complex-command, but
the command has the old region beg/end in it, and thus won't do what I
want.

Is repeat possible?  Is this my setup?

-- HASM





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to redo align-regexp?
  2016-10-05 17:02 how to redo align-regexp? HASM
@ 2016-10-05 17:45 ` Marco Wahl
  2016-10-05 22:49   ` HASM
  0 siblings, 1 reply; 9+ messages in thread
From: Marco Wahl @ 2016-10-05 17:45 UTC (permalink / raw)
  To: help-gnu-emacs

HASM <hasm@example.invalid> writes:

> I mark a region and run align-regexp.
>
> Then I mark a different region and attempt a repeat-complex-command, but
> the command has the old region beg/end in it, and thus won't do what I
> want.
>
> Is repeat possible?  [...]

What about running align-regexp again and using M-p to recover the
recent regexp?


HTH,
-- 
Marco Wahl


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to redo align-regexp?
  2016-10-05 17:45 ` Marco Wahl
@ 2016-10-05 22:49   ` HASM
  2016-10-06  7:42     ` Marco Wahl
                       ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: HASM @ 2016-10-05 22:49 UTC (permalink / raw)
  To: help-gnu-emacs


>> I mark a region and run align-regexp.
>> Then I mark a different region and attempt a repeat-complex-command, but
>> the command has the old region beg/end in it, and thus won't do what I
>> want.
>> Is repeat possible?  [...]

> What about running align-regexp again and using M-p to recover the
> recent regexp?

It's
  M-x ali TAB -r TAB M-p
a lot more keystrokes than
  C-x M-ESC 

I'll need to wrap align-regexp with a function that uses the current
region.

-- HASM





^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to redo align-regexp?
  2016-10-05 22:49   ` HASM
@ 2016-10-06  7:42     ` Marco Wahl
  2016-10-06 21:32       ` HASM
  2016-10-06 18:15     ` Robert Thorpe
  2016-10-07  1:47     ` Stefan Monnier
  2 siblings, 1 reply; 9+ messages in thread
From: Marco Wahl @ 2016-10-06  7:42 UTC (permalink / raw)
  To: help-gnu-emacs

HASM <hasm@example.invalid> writes:

>>> I mark a region and run align-regexp.
>>> Then I mark a different region and attempt a repeat-complex-command, but
>>> the command has the old region beg/end in it, and thus won't do what I
>>> want.
>>> Is repeat possible?  [...]
>
>> What about running align-regexp again and using M-p to recover the
>> recent regexp?
>
> It's
>   M-x ali TAB -r TAB M-p
> a lot more keystrokes than
>   C-x M-ESC 
>
> I'll need to wrap align-regexp with a function that uses the current
> region.

Not sure IIUC.  `align-regexp' actually already uses the current region
AFAICS.

Let me be more clear on what I suggest.

Let's say we have a buffer with the following 5 lines

a:a
aa:a
:
aaa:a
aaaa:a

Then you mark the first two lines and type M-x align-regexp : RET.  This
results in the first two lines to be aligned.

Then you mark the last two lines and type M-x M-p RET M-p RET.  This
results in the last two lines to be aligned.


HTH,
-- 
Marco


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to redo align-regexp?
  2016-10-05 22:49   ` HASM
  2016-10-06  7:42     ` Marco Wahl
@ 2016-10-06 18:15     ` Robert Thorpe
  2016-10-07  1:47     ` Stefan Monnier
  2 siblings, 0 replies; 9+ messages in thread
From: Robert Thorpe @ 2016-10-06 18:15 UTC (permalink / raw)
  To: help-gnu-emacs

HASM <hasm@example.invalid> writes:
> It's
>   M-x ali TAB -r TAB M-p
> a lot more keystrokes than
>   C-x M-ESC 
>
> I'll need to wrap align-regexp with a function that uses the current
> region.

In situations like this I use macros.  So, <f3> M-x align-regexp RET
M-p RET <f4>.  Then <f4> whenever I need to use it.

This isn't ideal of course.

BR,
Robert Thorpe



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to redo align-regexp?
  2016-10-06  7:42     ` Marco Wahl
@ 2016-10-06 21:32       ` HASM
  0 siblings, 0 replies; 9+ messages in thread
From: HASM @ 2016-10-06 21:32 UTC (permalink / raw)
  To: help-gnu-emacs


>> I'll need to wrap align-regexp with a function that uses the current
>> region.

> Not sure IIUC.  `align-regexp' actually already uses the current
> region AFAICS.

It does, if invoked directly, but repeat-complex-command brings back the
first invocation with the "old region", not the "current region".

> Let me be more clear on what I suggest.

I (almost) understood your suggestion.

> M-x M-p RET M-p RET.

OK, M-x M-p, is faster than re-running Mx align-regexp, but still C-X
M-ESC is even faster and burned into my brain/fingers from years of use.

-- HASM


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to redo align-regexp?
  2016-10-05 22:49   ` HASM
  2016-10-06  7:42     ` Marco Wahl
  2016-10-06 18:15     ` Robert Thorpe
@ 2016-10-07  1:47     ` Stefan Monnier
  2016-10-07  3:30       ` Michael Heerdegen
  2 siblings, 1 reply; 9+ messages in thread
From: Stefan Monnier @ 2016-10-07  1:47 UTC (permalink / raw)
  To: help-gnu-emacs

>>> Then I mark a different region and attempt a repeat-complex-command, but
>>> the command has the old region beg/end in it, and thus won't do what I
>>> want.

That's a bug (well, some may say it's a limitation of the current hack
that's used, but the result is the same).  Please report it via M-x
report-emacs-bug (you can put me in the "X-Debbugs-Cc:").
Fixing it will probably require some work, tho, so don't expect it to be
fixed quickly.

> It's
>   M-x ali TAB -r TAB M-p

Actually, since partial-completion is enabled by default (Emacs-23,
IIRC) you can skip the first TAB and go straight for

    M-x ali-r TAB

But in the present case, I guess

    M-x M-p

would work even better.


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to redo align-regexp?
  2016-10-07  1:47     ` Stefan Monnier
@ 2016-10-07  3:30       ` Michael Heerdegen
  2016-10-07 12:56         ` Stefan Monnier
  0 siblings, 1 reply; 9+ messages in thread
From: Michael Heerdegen @ 2016-10-07  3:30 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: help-gnu-emacs

Stefan Monnier <monnier@iro.umontreal.ca> writes:

> >>> Then I mark a different region and attempt a
> >>> repeat-complex-command, but
> >>> the command has the old region beg/end in it, and thus won't do
> >>> what I
> >>> want.
>
> That's a bug (well, some may say it's a limitation of the current hack
> that's used, but the result is the same).

I've seldom used that command, but I think the current behavior is also
sometimes useful: when the regexp you used didn't bring the result you
expected, you can now undo, and `repeat-complex-command' with a
different regexp without re-marking the region.


Michael.



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: how to redo align-regexp?
  2016-10-07  3:30       ` Michael Heerdegen
@ 2016-10-07 12:56         ` Stefan Monnier
  0 siblings, 0 replies; 9+ messages in thread
From: Stefan Monnier @ 2016-10-07 12:56 UTC (permalink / raw)
  To: help-gnu-emacs

> I've seldom used that command, but I think the current behavior is also
> sometimes useful:

Sure.  But it's still a bug: the `interactive` handler tries to
recognize when the region is passed as an argument and replace the
integer positions in the history with calls to get the
region's position.

The bug is that it *tries to recognize*, which is fairly naive (and
ultimately is impossible (literally) to do reliably anyway).


        Stefan




^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-10-07 12:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-05 17:02 how to redo align-regexp? HASM
2016-10-05 17:45 ` Marco Wahl
2016-10-05 22:49   ` HASM
2016-10-06  7:42     ` Marco Wahl
2016-10-06 21:32       ` HASM
2016-10-06 18:15     ` Robert Thorpe
2016-10-07  1:47     ` Stefan Monnier
2016-10-07  3:30       ` Michael Heerdegen
2016-10-07 12:56         ` Stefan Monnier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).