From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ihor Radchenko Subject: Asynchronous org-agenda-redo Date: Thu, 12 Dec 2019 16:18:25 +0800 Message-ID: <87k172ot2m.fsf@yantar92-laptop.i-did-not-set--mail-host-address--so-tickle-me> Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:44381) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ifJj0-0006pU-GC for emacs-orgmode@gnu.org; Thu, 12 Dec 2019 03:21:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ifJiz-0000vH-Dw for emacs-orgmode@gnu.org; Thu, 12 Dec 2019 03:21:30 -0500 Received: from mail-pf1-x433.google.com ([2607:f8b0:4864:20::433]:35231) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ifJiz-0000uz-8P for emacs-orgmode@gnu.org; Thu, 12 Dec 2019 03:21:29 -0500 Received: by mail-pf1-x433.google.com with SMTP id b19so362959pfo.2 for ; Thu, 12 Dec 2019 00:21:28 -0800 (PST) Received: from localhost ([5.226.137.4]) by smtp.gmail.com with ESMTPSA id 203sm6016668pfy.185.2019.12.12.00.21.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Dec 2019 00:21:27 -0800 (PST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode Mailinglist I am thinking if it is possible to implement org-agenda-redo asynchronously. Rebuilding agenda should normally not affect any buffer except agenda buffer. So, it should be sufficient to block any agenda modifying commands in the agenda buffer, redo the agenda buffer in separate thread, and replace the old agenda with the calculated one. Then, emacs should remain responsive while updating agenda (except for modifying the agenda buffer). For example, this naive code kind of works (forgetting that buffer-local variables will not be passed to the thread): (define-advice org-agenda-redo (:around (oldfun &optional all) make-async) (make-thread oldfun "org-agenda-redo")) The problem is that emacs does not become responsive... Another approach would be using async.el package, which allows calling arbitrary function in subordinate emacs process. Then, the main emacs instance should not be "frozen" (I use same approach for tangling and it works fine). However, the question is how to pass the .org and agenda buffers to this subordinate process. Opening the .org files there is not a good option since it would give too much overhead to this asynchronous agenda. Any suggestions? Alternative ideas? Best, Ihor