From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms1.migadu.com with LMTPS id mLOhCNGcWWZ2rgAAqHPOHw:P1 (envelope-from ) for ; Fri, 31 May 2024 11:48:01 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id mLOhCNGcWWZ2rgAAqHPOHw (envelope-from ) for ; Fri, 31 May 2024 11:48:01 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=FrfqmiOp; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1717148881; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=5VJ9+wpKMAUG+QXzAYkM3va4jnqtio6yi8T5WrjT0OE=; b=CaSeyNLmpfipnT172ti5ty1RH3zLrfMEWzSBLRU4a174BXfp4/6gyRzPFrSeQKW680FvKG LkCHJwB92B9E0KHrU7ZBGBSAjQFWdDHG2U1U2Y893yri3dLBzoLPwKt6B+CKwDWkgLTciK P19V/V2yhhwDlYMilv+gnB0qbc0Vh16iXDnRll36y6hSrXdqmDkd7nCBzpT6Bo/2UqcCh0 yHIJxD1AN840B98vuKkcGQHAOWmnH80yPNwSSMrIjhAjx43nWTYSBRzyntg0GtbZJFMUG8 ILuzkyjZMkacj/eMT1weZcRD3Es+6SLI+/WGU7wyULwisyBw6GmdbyPo6cgq0A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=FrfqmiOp; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org"; dmarc=pass (policy=none) header.from=posteo.net ARC-Seal: i=1; s=key1; d=yhetil.org; t=1717148881; a=rsa-sha256; cv=none; b=WUSM47ybNoD6KoskY3bB5luEptWIMw8S2dghxCjL6FiUWHItvU8tqFgJ1x35cJfaZP9uUW 3wmSj2hvilJTbMdOgUWPmK3TGxNxdqzvybri5nTPsX9o4DaaQMaCWKX8Pw9zemEkA0VQ9v gmkH8kp6wlGU4bzmlANWhh0PNtsAN85L/twNxSk3l5D097Es31SJW2kbfc1sMxKcHBmGW5 jBNxlwTB4MU1WbVpoqNna9mxZvrMG2jMsNkIOXSSkdYGHlDlmcqRIUWv1DgaVA3pAAsrz/ E0vNLK+ABuYzdx1ag/RIMc7s8Ho5ZFqwhLjw/BP5J3PC4PspQHp9Ei5TfK/CZA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 9C334213EE for ; Fri, 31 May 2024 11:48:00 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sCyqf-0003nz-Ak; Fri, 31 May 2024 05:46:57 -0400 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 1sCyqa-0003le-K7 for emacs-orgmode@gnu.org; Fri, 31 May 2024 05:46:52 -0400 Received: from mout01.posteo.de ([185.67.36.65]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sCyqY-00035G-8L for emacs-orgmode@gnu.org; Fri, 31 May 2024 05:46:52 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 4FB7F240027 for ; Fri, 31 May 2024 11:46:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1717148807; bh=O1p0s1l+NJwy4uPLbKZDz6y9NvzT3uN41K6AjvVmXvU=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type: From; b=FrfqmiOpCgQuImshQBSW37hd9dDDFCfjQBFYef7i2rZaVIMNWMWhxPWLN/E/g2bK6 CLJO7ICZjGLLrM+Cb6vlkNAhOm1EyufUqUrDh9D+tEICup3/YjNWE/4ySdXDap4MFq BpWcWfcV1/HiAbfqZK8/aT2h2UahI3fBw1JKUNcSPUzwXgBdqSaE1u6/raMgxYUtVP rcmzfyhVGUZEakGuTwGo4iLfl8mALBz/wgWajnFzK1PCyQF50lMnfopMvWwjNPlVkZ C2if8XGh5nMC+G/5WHTNgntp7/yzfF54f+fizIr1lskeH1GlFckwV1/blWvXQ6zvGH MoKMdbGBZCRMg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4VrJDQ40pYz9rxL; Fri, 31 May 2024 11:46:46 +0200 (CEST) From: Ihor Radchenko To: Bruno Barbier Cc: emacs-orgmode , Jack Kamm , Matt Subject: Re: Pending contents in org documents (Re: Asynchronous blocks for everything (was Re: ...)) In-Reply-To: <6658cd1f.050a0220.f6605.de1a@mx.google.com> References: <87o7d0mm54.fsf@localhost> <87edct0x2w.fsf@localhost> <65e30609.050a0220.89c06.1798@mx.google.com> <87a5ng7uoq.fsf@localhost> <65e9f49b.df0a0220.11103.1c10@mx.google.com> <87ttlhki9e.fsf@localhost> <65eb1e60.050a0220.337b2.a0f4@mx.google.com> <87frwuxy1b.fsf@localhost> <65f95bf2.050a0220.6d051.c8b1@mx.google.com> <87plvpjj76.fsf@localhost> <65fc06c1.5d0a0220.0d53.efdc@mx.google.com> <87frwjlr1a.fsf@localhost> <6601b872.050a0220.31a67.5a55@mx.google.com> <87le63c3qy.fsf@localhost> <660ed63d.050a0220.36fdd.af23@mx.google.com> <87cyqwyvgw.fsf@localhost> <66225435.5d0a0220.f60e4.c590@mx.google.com> <87r0f02vq2.fsf@localhost> <664f6f54.050a0220.10342.b002@mx.google.com> <87o78vwnds.fsf@localhost> <6658cd1f.050a0220.f6605.de1a@mx.google.com> Date: Fri, 31 May 2024 09:48:28 +0000 Message-ID: <87jzja71n7.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.65; envelope-from=yantar92@posteo.net; helo=mout01.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 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, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Spam-Score: -8.06 X-Migadu-Queue-Id: 9C334213EE X-Migadu-Scanner: mx10.migadu.com X-Migadu-Spam-Score: -8.06 X-TUID: dNpP8XqVqrGi Bruno Barbier writes: > ... I'm now using using a fully working example. Thanks! I will first reply to you email inline and then common further on your changes from the branch. >>> ;; (org-pending-send-update my-rlock (list :progress "Not ready yet.")) >>> ;; (org-pending-send-update my-rlock (list :progress "Coming soon.")) >> >> Should the progress message always be a string? > > No. It may currently be any data. org-pending will format it as a > string that fits on one line. Please say this in the docstring of `org-pending-send-update'. >>> ;; (org-pending-send-update my-rlock (list :success 1)) >> >> What will org-pending do with :success 1? Will it replace region with >> "1" or will it do something else? > > That's the job on ON-OUTCOME to convert/format/append/prepend/replace > some content if needed, on :success and/or on :failure. Fair. Although, it feels like a common use case to replace the region with :success value. Maybe the library should provide some ready-to-use functions that can be used as the value of :on-outcome. >> It would be nice to have an example that will also send a signal to >> process, as it is probably the most commonly used way to utilize >> org-pending. > > For my many use cases, that would always be a mistake to kill the > process: an OS process is always in charge of many locks. > > More importantly, to find a self-contained working readable example > might be a challenge. > > We could add a function 'org-pending-shell-command-on-region' in > org-pending, that could be used as an implementation example, like > `org-pending-user-edit', `org-babel-execute-src-block', etc. Yes, having pre-cooked wrappers for `org-pending' or pre-defined values for :on-outcome/:befire-kill-function/:user-cancel-function/etc would be useful. ;; ;; We lock the 'region', defining how to update it when the ;; ;; outcome is available. ;; (setq my-lock (org-pending ;; region ;; :on-outcome ;; (lambda (_rl outcome) ;; (pcase outcome ;; (`(:success ,value) ;; ;; On :success, we replace the region with the ;; ;; value. ;; (let ((tmp-end (cdr region))) ;; (goto-char tmp-end) ;; (insert (format "%s\n" value)) ;; (setcdr region (point)) ;; (delete-region (car region) tmp-end))) ;; ... This example has a major problem if user edits the buffer text _before_ locked region before the outcome is available. (car region) and (cdr region) will no longer be accurate, and your code will replace text in places you do not expect. I believe that it will be better to query region-lock object about the region location where we need to replace text: (setq region (org-pending-reglock-region rl)) Same for reglock buffer in other examples. Then, we will keep the possibility open for org-pending to handle cases like killing/yanking text containing reglocks (org-refile) - org-pending may in future keep track of them. ;; (setf (org-pending-reglock-user-cancel-function my-lock) ;; (let ((this-timer my-timer)) ;; (lambda (_rl) ;; (cancel-timer this-timer) ;; ... ;; (setf (org-pending-reglock-before-kill-function my-lock) ;; (let ((this-timer my-timer)) ;; (lambda (_rl) ;; (message "Killing %s" this-timer) ;; (cancel-timer this-timer)))) What is the difference between "canceling" and "killing" the reglock? Do they need to be separate? -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at