From: yyoncho <yyoncho@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: Eli Zaretskii <eliz@gnu.org>, emacs-devel <emacs-devel@gnu.org>
Subject: Re: Questions about throw-on-input
Date: Fri, 8 May 2020 07:36:42 +0300 [thread overview]
Message-ID: <CACCVLQVykSeOF5diO-w8EQ6m1uN01wQQVUzsvx0C0CO0VK+p8g@mail.gmail.com> (raw)
In-Reply-To: <jwvsggbxka0.fsf-monnier+emacs@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 3840 bytes --]
Hi Stefan,
Thank you for your reply! Can you elaborate on "won't have the desired
semantics"? I would suggest something crazier - using inhibit-quit to
Thanks,
Ivan
On Fri, May 8, 2020 at 4:59 AM Stefan Monnier <monnier@iro.umontreal.ca>
wrote:
> > Out of curiosity, do you think that having a function
> > (process-events) which will process all keyboard(?) events
> > and resume the current invocation can be implemented easily?
>
> It can be implemented, but it won't have the desired semantics.
> If you want something robust you have 2 options:
>
> - write in an event-driven style (or CPS style) so that you can easily
> stop at various points in the program and stash the rest of the
> computation for later.
>
> - use a thread (which will basically do the same, but transparently,
> i.e. without the awkward programming style.)
>
>
> Stefan
>
>
> > AFAIK a lot of gui toolkits have that kind of function, e. g.
> >
> https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.application.doevents?view=netcore-3.1
> >
> > IMO it will be very useful for certain cases.
> >
> > Thanks,
> > Ivan
> >
> > On Thu, May 7, 2020 at 3:37 PM Eli Zaretskii <eliz@gnu.org> wrote:
> >
> >> > From: Ivan Yonchovski <yyoncho@gmail.com>
> >> > Date: Thu, 07 May 2020 10:31:23 +0300
> >> >
> >> >
> >> > 1. In the following example:
> >> >
> >> > (dotimes (_ 10)
> >> > (message "Length %s"
> >> > (length
> >> > (let (result)
> >> > (catch t
> >> > (let ((throw-on-input t))
> >> > (dotimes (counter 10000000)
> >> > (push (number-to-string counter) result))))
> >> > result))))
> >> >
> >> > .. after I execute the following block each of the 10 computations
> will
> >> be
> >> > canceled after pressing C-n for example, how do I force the handling
> of
> >> > the command to be processed? I tried redisplay but it does not help.
> >>
> >> Invoking redisplay won't help because the commands which interrupted
> >> the inner loop (C-n) were not yet executed. Emacs will process them
> >> only after the outer loop ends, because that outer loop is the last
> >> command, and it is still being executed. Emacs doesn't perform
> >> commands in the middle of another command.
> >>
> >> > (message "Length %s"
> >> > (length
> >> > (let (result)
> >> > (catch t
> >> > (let ((throw-on-input t))
> >> > (dotimes (counter 10000000)
> >> > (push (number-to-string counter) result))))
> >> > result)))
> >> >
> >> >
> >> > (run-with-idle-timer
> >> > 0.0
> >> > nil
> >> > (lambda ()
> >> > (message "Length %s"
> >> > (length
> >> > (let (result)
> >> > (catch t
> >> > (let ((throw-on-input t))
> >> > (dotimes (counter 10000000)
> >> > (push (number-to-string counter) result))))
> >> > result)))))
> >> >
> >> > The issue is with the second block, it seems like throw-on-input is
> >> > disregarded when used in run-with-idle-timer. Can anyone confirm if
> this
> >> > is a bug/desired behavior or I should use something else if I want to
> >> > run cancelable tasks in on-idle?
> >>
> >> When the time function is run, Emacs binds inhibit-quit to t (so that
> >> the user's C-g would not interrupt the timer function, for example).
> >> And throw-on-input uses quitting to do its job.
> >>
> >> Why do you need to interrupt an idle timer like that? The usual way
> >> of doing this is not to call expensive functions in an idle timer, and
> >> if you have a lot of processing, divide them into small enough chunks
> >> and do it piecemeal. That's what jit-stealth font-lock does, for
> >> example.
> >>
>
>
[-- Attachment #2: Type: text/html, Size: 5553 bytes --]
next prev parent reply other threads:[~2020-05-08 4:36 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-07 7:31 Questions about throw-on-input Ivan Yonchovski
2020-05-07 12:36 ` Eli Zaretskii
2020-05-07 14:28 ` Ivan Yonchovski
2020-05-07 21:11 ` yyoncho
2020-05-08 1:58 ` Stefan Monnier
2020-05-08 4:36 ` yyoncho [this message]
2020-05-08 4:43 ` yyoncho
2020-05-12 4:15 ` Michael Heerdegen
2020-05-08 10:41 ` Eli Zaretskii
2020-05-08 11:23 ` Ivan Yonchovski
2020-05-08 11:45 ` Eli Zaretskii
2020-05-08 11:55 ` yyoncho
2020-05-08 14:55 ` Stefan Monnier
2020-05-08 18:04 ` yyoncho
2020-05-07 13:49 ` Stefan Monnier
2020-05-07 15:36 ` Ivan Yonchovski
-- strict thread matches above, loose matches on Subject: below --
2020-05-09 13:09 Alexander Miller
2020-05-10 11:11 ` yyoncho
2020-05-10 13:47 Alexander Miller
2020-05-11 14:13 ` Eli Zaretskii
2020-05-11 15:21 ` Stefan Monnier
2020-05-11 16:19 ` Eli Zaretskii
2020-05-11 17:27 ` Stefan Monnier
2020-05-11 17:39 ` Alexander Miller
2020-05-11 18:23 ` Eli Zaretskii
2020-05-11 18:24 ` Stefan Monnier
2020-05-11 19:48 ` Alexander Miller
2020-05-11 20:14 ` Stefan Monnier
2020-05-12 22:33 ` Alexander Miller
2020-05-13 14:43 ` Eli Zaretskii
2020-05-13 18:47 ` Alexander Miller
2020-05-14 8:32 ` Philipp Stephani
2020-05-14 14:23 ` Eli Zaretskii
2020-05-14 14:37 ` Philipp Stephani
2020-05-14 16:56 ` Drew Adams
2020-05-15 3:21 ` Richard Stallman
2020-05-15 3:54 ` Stefan Monnier
2020-05-15 8:19 ` Arthur Miller
2020-05-15 15:45 ` Stefan Monnier
2020-05-15 16:46 ` Yuan Fu
2020-05-15 17:31 ` Stefan Monnier
2020-05-15 17:50 ` yyoncho
2020-05-15 18:44 ` Alexander Miller
2020-05-15 18:55 ` Stefan Monnier
2020-05-15 19:46 ` Philipp Stephani
2020-05-15 18:00 ` Andrea Corallo
2020-05-15 17:35 ` Arthur Miller
2020-05-15 19:47 ` chad
2020-05-16 11:29 ` Eli Zaretskii
2020-05-12 2:39 ` Daniel Colascione
2020-05-12 14:37 ` Eli Zaretskii
2020-05-11 18:17 ` Eli Zaretskii
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=CACCVLQVykSeOF5diO-w8EQ6m1uN01wQQVUzsvx0C0CO0VK+p8g@mail.gmail.com \
--to=yyoncho@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
/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.