From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Ivan Yonchovski Newsgroups: gmane.emacs.devel Subject: Re: Questions about throw-on-input Date: Fri, 08 May 2020 14:23:34 +0300 Message-ID: <87v9l67jrd.fsf@gmail.com> References: <87r1vwxktw.fsf@gmail.com> <831rnvly58.fsf@gnu.org> <83r1vuiu90.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="105319"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.3.7; emacs 27.0.91 Cc: emacs-devel@gnu.org To: Eli Zaretskii Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri May 08 13:24:55 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jX17f-000RI3-7x for ged-emacs-devel@m.gmane-mx.org; Fri, 08 May 2020 13:24:55 +0200 Original-Received: from localhost ([::1]:37492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jX17e-0006TG-9J for ged-emacs-devel@m.gmane-mx.org; Fri, 08 May 2020 07:24:54 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:59454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jX16S-0005BA-Ti for emacs-devel@gnu.org; Fri, 08 May 2020 07:23:40 -0400 Original-Received: from mail-lj1-x22c.google.com ([2a00:1450:4864:20::22c]:41545) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jX16R-0000Q9-3Z; Fri, 08 May 2020 07:23:40 -0400 Original-Received: by mail-lj1-x22c.google.com with SMTP id j3so1264192ljg.8; Fri, 08 May 2020 04:23:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=references:user-agent:from:to:cc:subject:in-reply-to:date :message-id:mime-version; bh=kOnsuKINiEDAzE8OkZP1cHoSfgkQcAnbbHU4tpI5YOI=; b=JivJGGrCnUWeGoyGHBWNHtidIH+BJw+2EA61eEUbUxfIjyyfO13ET1ek/EwPieeh+/ iSRo4NrsVr2fhFiJBh/26/tff3GG359BkywVH7ROd6rIKTNAPadBmYFXU6zDokgILEzx V3maWeKm0wKfNo0j2HnlMMo1H1kFIQj+FlCDpgsE2sAbi3+0wmxf4k9om/KAHejLBv4W CVl3gkwDhnUsOWZJIUP+SZIGgvaRKRpSuOYkWvxI28hnzqhPLVvwxTaSKF43Hbr7houW qtyqXDQAX8P/uYMVpkk2iG27wqI8yuG+Iw9LmWYH7XMDTeMQtJECels6MUd/q7jmZGMp LNmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:references:user-agent:from:to:cc:subject :in-reply-to:date:message-id:mime-version; bh=kOnsuKINiEDAzE8OkZP1cHoSfgkQcAnbbHU4tpI5YOI=; b=O5Qe5o0g3xEP3GhpQIWA6E9Qqw2151RnpP2q006YFfWgj+qlNoazzahSZF/Rct2I63 7PpLNicf3oxv4r+LN3TQMcLgUKCNfxplhJZB00eENpueMak99r8GavHkVr1J+syMO4Pa iUBPfvlzGRbXfx3FSgMqCHgbGPK2/lSw8AP1xOF0ATGlBPxphGFzP3ZsJqo/1uDjpCwp TYKPjASoaPJ0XbTbq/Ykbv5r/CdQQW6ePnRTf6SBgW7vqv48VoNe5+5bYRafyHD9JXHG M/CSWQFB+DMz/tylZHfLN1+kyhj/pPAKnrq7WKo9HZTRwwBx+wmYc1jkxteBhd56BbGC db1A== X-Gm-Message-State: AOAM532tGsHck2XmXrB7FiSYMccphL7n3HC1wLXNfa4uMvpxkRmmtMSE PiXeIq6HZC5um5cKmuU7ADpjMBg+m1g= X-Google-Smtp-Source: ABdhPJwHOofaaSywwAZWZ+zsr/tGMXh6iHZmAeVbN4Zhv6WJpxUufzt9RRnuj+wyjtkLsfRfT/PeVw== X-Received: by 2002:a2e:553:: with SMTP id 80mr1369923ljf.147.1588937016430; Fri, 08 May 2020 04:23:36 -0700 (PDT) Original-Received: from kyoncho-H87-D3H ([2a00:4802:28d:1200:cc4:b919:feeb:ce46]) by smtp.gmail.com with ESMTPSA id w9sm999569ljw.39.2020.05.08.04.23.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 May 2020 04:23:35 -0700 (PDT) In-reply-to: <83r1vuiu90.fsf@gnu.org> Received-SPF: pass client-ip=2a00:1450:4864:20::22c; envelope-from=yyoncho@gmail.com; helo=mail-lj1-x22c.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:249263 Archived-At: Hi Eli, > By "processing all keyboard events" do you mean invoking the commands > those events are bound to? Yes. > If so, I don't think we have machinery to do that in Emacs: there's > too much of global state that would get in the way. Here it is overly simplistic code that is close to what I am trying to achieve. (defun process-events () (when (input-pending-p) (run-with-timer 0.01 nil (lambda () (throw 'exit nil))) (recursive-edit))) (dotimes (counter 1000) (sleep-for 0.01) ;; simulate execution of N tasks (message "%s" counter) (process-events)) This code is able to handle C-n but obviously it will break if someone starts another recursive-edit or for complex keybindings, e. g. `C-x b`. Are you aware of something doing something similar? Do you think it makes sense if you want to process something slow on the background without blocking emacs? > AFAIU, such facilities need to have a separate event loop that > generally runs in a separate thread. In the C# case it all happens on the UI thread. DoEvents means handle mouse clicks, repaint controls, etc(the stuff from the event loop) and then continue with current execution. Thanks, Ivan