unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* How about making `sleep-for' interactive?
@ 2019-06-27  4:43 Marcin Borkowski
  2019-06-27  7:46 ` Søren Pilgård
  2019-06-27 19:40 ` Noam Postavsky
  0 siblings, 2 replies; 6+ messages in thread
From: Marcin Borkowski @ 2019-06-27  4:43 UTC (permalink / raw)
  To: Emacs developers

Hi all,

I noticed today that `sleep-for' is not an (interactive) command.  IMHO
it should be - at least I can see a need for it.  Here is my use case.
I recorded a keyboard macro which edits the text in some way.  The macro
begins with isearching for something (which may be outside the part of
the buffer currently seen) and then changing.  Having e.g. a 1-second
delay between moving to that part and actually changing it would help
spot mistakes.

Since `sleep-for' is a builtin, I can't prepare a patch (I don't speak
C very well), but if I get a hint I can try (just to learn something
new).

WDYT?

--
Marcin Borkowski
http://mbork.pl



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

* Re: How about making `sleep-for' interactive?
  2019-06-27  4:43 How about making `sleep-for' interactive? Marcin Borkowski
@ 2019-06-27  7:46 ` Søren Pilgård
  2019-06-27  7:55   ` Marcin Borkowski
  2019-06-27 19:40 ` Noam Postavsky
  1 sibling, 1 reply; 6+ messages in thread
From: Søren Pilgård @ 2019-06-27  7:46 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Emacs developers

On Thu, Jun 27, 2019 at 6:47 AM Marcin Borkowski <mbork@mbork.pl> wrote:
>
> Hi all,
>
> I noticed today that `sleep-for' is not an (interactive) command.  IMHO
> it should be - at least I can see a need for it.  Here is my use case.
> I recorded a keyboard macro which edits the text in some way.  The macro
> begins with isearching for something (which may be outside the part of
> the buffer currently seen) and then changing.  Having e.g. a 1-second
> delay between moving to that part and actually changing it would help
> spot mistakes.
>
> Since `sleep-for' is a builtin, I can't prepare a patch (I don't speak
> C very well), but if I get a hint I can try (just to learn something
> new).
>
> WDYT?
>

I can't really see the use.
You could always just do ```M-: (sleep-foor xxx)``` in the macro.
Being time sensitive and waiting for abortion is a bit too dangerous
in my taste, either I am sure and do it everywhere or I want to accept
/ decline in cases like that.

What I usually do in cases like that is to make a macro that moves to
the next occurrence, then does the changes and then moves to just the
beginning of the next occurrence again.
That way I can just call the macro repeatedly and it will move forward
to the next place where a change will happen each time.
If I decide not to apply the macro I will skip forward, either
searching manually for the next occurrence or sometimes just moving
the point forward so the macro will edit the next occurrence instead.



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

* Re: How about making `sleep-for' interactive?
  2019-06-27  7:46 ` Søren Pilgård
@ 2019-06-27  7:55   ` Marcin Borkowski
  2019-06-27 13:19     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Marcin Borkowski @ 2019-06-27  7:55 UTC (permalink / raw)
  To: Søren Pilgård; +Cc: Emacs developers


On 2019-06-27, at 09:46, Søren Pilgård <fiskomaten@gmail.com> wrote:

> On Thu, Jun 27, 2019 at 6:47 AM Marcin Borkowski <mbork@mbork.pl> wrote:
>>
>> Hi all,
>>
>> I noticed today that `sleep-for' is not an (interactive) command.  IMHO
>> it should be - at least I can see a need for it.  Here is my use case.
>> I recorded a keyboard macro which edits the text in some way.  The macro
>> begins with isearching for something (which may be outside the part of
>> the buffer currently seen) and then changing.  Having e.g. a 1-second
>> delay between moving to that part and actually changing it would help
>> spot mistakes.
>>
>> Since `sleep-for' is a builtin, I can't prepare a patch (I don't speak
>> C very well), but if I get a hint I can try (just to learn something
>> new).
>>
>> WDYT?
>>
>
> I can't really see the use.
> You could always just do ```M-: (sleep-foor xxx)``` in the macro.
> Being time sensitive and waiting for abortion is a bit too dangerous
> in my taste, either I am sure and do it everywhere or I want to accept
> / decline in cases like that.
>
> What I usually do in cases like that is to make a macro that moves to
> the next occurrence, then does the changes and then moves to just the
> beginning of the next occurrence again.
> That way I can just call the macro repeatedly and it will move forward
> to the next place where a change will happen each time.
> If I decide not to apply the macro I will skip forward, either
> searching manually for the next occurrence or sometimes just moving
> the point forward so the macro will edit the next occurrence instead.

Good points.  In addition to that, I discovered that screen is not
updated during macro execution, so my solution would have to involve
updating the display.

Let's forget about this idea.

Thanks,

-- 
Marcin Borkowski
http://mbork.pl



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

* Re: How about making `sleep-for' interactive?
  2019-06-27  7:55   ` Marcin Borkowski
@ 2019-06-27 13:19     ` Stefan Monnier
  2019-06-27 13:32       ` Søren Pilgård
  0 siblings, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2019-06-27 13:19 UTC (permalink / raw)
  To: emacs-devel

> Good points.  In addition to that, I discovered that screen is not
> updated during macro execution, so my solution would have to involve
> updating the display.

The screen updating is not disabled during kbd-macro execution.
What happens is that the screen is only updated when Emacs is "idle".

Notice that `sleep-for` says:

    Pause, without updating display, for SECONDS seconds.

But you can use `sit-for` instead, which does update the display (by
default).


        Stefan




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

* Re: How about making `sleep-for' interactive?
  2019-06-27 13:19     ` Stefan Monnier
@ 2019-06-27 13:32       ` Søren Pilgård
  0 siblings, 0 replies; 6+ messages in thread
From: Søren Pilgård @ 2019-06-27 13:32 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: Emacs developers

On Thu, Jun 27, 2019 at 3:22 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
> > Good points.  In addition to that, I discovered that screen is not
> > updated during macro execution, so my solution would have to involve
> > updating the display.
>
> The screen updating is not disabled during kbd-macro execution.
> What happens is that the screen is only updated when Emacs is "idle".
>
> Notice that `sleep-for` says:
>
>     Pause, without updating display, for SECONDS seconds.
>
> But you can use `sit-for` instead, which does update the display (by
> default).
>
>

Would it make sense the sleep-for help text to mention sit-for?



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

* Re: How about making `sleep-for' interactive?
  2019-06-27  4:43 How about making `sleep-for' interactive? Marcin Borkowski
  2019-06-27  7:46 ` Søren Pilgård
@ 2019-06-27 19:40 ` Noam Postavsky
  1 sibling, 0 replies; 6+ messages in thread
From: Noam Postavsky @ 2019-06-27 19:40 UTC (permalink / raw)
  To: Marcin Borkowski; +Cc: Emacs developers

On Thu, 27 Jun 2019 at 00:45, Marcin Borkowski <mbork@mbork.pl> wrote:

> I noticed today that `sleep-for' is not an (interactive) command.

> Since `sleep-for' is a builtin, I can't prepare a patch (I don't speak
> C very well), but if I get a hint I can try (just to learn something
> new).

FYI, you can make any function interactive by setting its
interactive-form symbol property. For example,

(put 'sleep-for 'interactive-form
     '(interactive "nSleep for: "))



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

end of thread, other threads:[~2019-06-27 19:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-27  4:43 How about making `sleep-for' interactive? Marcin Borkowski
2019-06-27  7:46 ` Søren Pilgård
2019-06-27  7:55   ` Marcin Borkowski
2019-06-27 13:19     ` Stefan Monnier
2019-06-27 13:32       ` Søren Pilgård
2019-06-27 19:40 ` Noam Postavsky

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

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