From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.devel Subject: A UI approach for making synchronous commands asynchronous Date: Wed, 26 Jul 2023 15:07:39 -0400 Message-ID: Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="32508"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: emacs-devel@gnu.org Cancel-Lock: sha1:Qu36Lv6TFX6eif4mYn7bzhc/9NE= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Thu Jul 27 06:45:22 2023 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 1qOssM-0008FD-2M for ged-emacs-devel@m.gmane-mx.org; Thu, 27 Jul 2023 06:45:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qOslP-0004Sm-EW; Thu, 27 Jul 2023 00:38:11 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOjre-0004s6-51 for emacs-devel@gnu.org; Wed, 26 Jul 2023 15:08:02 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qOjrc-0004x0-6X for emacs-devel@gnu.org; Wed, 26 Jul 2023 15:08:01 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1qOjrU-0009HB-Uh for emacs-devel@gnu.org; Wed, 26 Jul 2023 21:07:53 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -16 X-Spam_score: -1.7 X-Spam_bar: - X-Spam_report: (-1.7 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.249, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 27 Jul 2023 00:38:10 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:308132 Archived-At: Basic well known facts: - Sometimes Emacs blocks for a long time while performing a command - This is annoying because I don't want to sit and wait - Making it so I don't have to sit and wait requires two things: Step 1. Changing the implementation of the command (to be capable of running while Emacs handles user input) Step 2. Changing the user interface of the command (e.g. to display a buffer or message when the command is done) Step 1 is difficult on its own and is specific to individual commands. I'm not going to talk about step 1 at all. (We've talked about it a lot recently in the "Concurrency via isolated process/thread" thread) Instead, I have an idea for step 2! Even once step 1 is already done, step 2 is still a bunch of work: we have to design a non-blocking UI for the command. For a lot of commands, this is difficult. Changing the UI to be non-blocking is a big compatibility break, and can confuse and annoy users, and can be just plain worse in the common case of a short-running command. We could make blocking vs non-blocking configurable for each command, but that adds more annoying configuration overhead. Instead, perhaps we could add a new basic Emacs feature, "backgrounding", inspired by job control (C-z) in Unix shells. Commands supporting this feature could start out with a blocking UI. When such a command is run, Emacs just blocks and doesn't respond to user input. The user can wait for as long as they like, and can interrupt it with C-g. This is how things are today. The new feature is that if they get annoyed with how long a command is taking, they can hit C-M-z to make the command "go into the background": convert to some kind of non-blocking UI, like displaying a buffer with progress or messaging when the task is done, as appropriate for the individual command. We could also have a prefix (perhaps C-M-&) to run a command in the "background" - that is, in a non-blocking way - from the beginning. This UI approach: - Doesn't break UI compatibility - Doesn't require any configuration - Lets users decide on what they want on a case-by-case basis - Is already familiar to anyone who uses job control in Unix shells In particular, I was thinking about this for file operations in dired. Many dired file operations can take a long time, during which they block Emacs. Actually changing their implementation to run during user input handling (step 1) is a separate matter (and I have separate ideas about how to do that), but I think the UI aspect (step 2) would be well served by this "backgrounding" approach. I think this approach would also work well for some other commands. Thoughts?