From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id 0A35AJruLWKNKgAAgWs5BA (envelope-from ) for ; Sun, 13 Mar 2022 14:16:10 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id AEIWOZnuLWL6sQAAauVa8A (envelope-from ) for ; Sun, 13 Mar 2022 14:16:09 +0100 Received: from mail.notmuchmail.org (yantan.tethera.net [135.181.149.255]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 771A83F03D for ; Sun, 13 Mar 2022 14:16:09 +0100 (CET) Received: from yantan.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 070BE5E017; Sun, 13 Mar 2022 13:16:07 +0000 (UTC) X-Greylist: delayed 300 seconds by postgrey-1.36 at yantan; Sun, 13 Mar 2022 02:35:03 UTC Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by mail.notmuchmail.org (Postfix) with ESMTPS id C25CD5F6CE for ; Sun, 13 Mar 2022 02:35:03 +0000 (UTC) Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1nTDzd-00005G-UD for notmuch@notmuchmail.org; Sun, 13 Mar 2022 03:30:01 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: notmuch@notmuchmail.org From: Preston Miller Firestone <0x504d46@disroot.org> Subject: WIP: asynchronous notmuch-poll in emacs client Date: Sat, 12 Mar 2022 20:53:36 -0500 Message-ID: <87ee36obxb.fsf@disroot.org> Mime-Version: 1.0 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cancel-Lock: sha1:5EY03OyQbC47hO2bJqzcyadvHNY= X-MailFrom: gmn-notmuch@m.gmane-mx.org X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0 Message-ID-Hash: XYPVD5JIS67EJWQF6WMYHI2WIKM2CMNX X-Message-ID-Hash: XYPVD5JIS67EJWQF6WMYHI2WIKM2CMNX X-Mailman-Approved-At: Sun, 13 Mar 2022 13:16:04 +0000 X-Mailman-Version: 3.3.3 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN X-Migadu-To: larch@yhetil.org X-Migadu-Country: DE ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1647177369; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-owner:list-unsubscribe:list-subscribe:list-post; bh=N8qSkrqPJu9EwwdPoyBCs/lgkkiN+gJfG7GuLY7OxBo=; b=RmSg15E5cAdjRAd/rE+7SSEx1VirisOMtSLyIz+oRg3GEJDOidl1aPayWNLzR0cEla170q OT7t1/f11IjyUHMNyoFPLOiFwLhWfX4CsRjfA/NHt7SsD9FqHzlJzlJDm1hG518kwRxYA9 0vSLrUEp7QwTZVFcIvGuLIT8zCbqRggsXikaLIgP1rtqs1uxD7MKI+MQItQ3/IAflJZeod fPlhOzwU28Qp+CQjkiLe/okmaWwAR4xXSy5BO/wSsw8gUTOkjmoVKw/5Ztrbfp1dtJsDdI zxfH2xzklI8vL714mzGeKtr3n0KS+sQ+TYWDnAU0ONgaXPfIiwRpj0/Sm+SnLA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1647177369; a=rsa-sha256; cv=none; b=HKXoQhdVG975NzrjoCG78OTcqd6+6NnjmudCkbL3sLqlAqcSTl02UeYvivJKb5Z7H0ThJh BlL6+nQDtckeHXR0rZLJwZ39WT8FRDJeM9aheUnfgvkNqfUJp4ooxUbl3orCI5QRtK5FE+ 59fhYgWLdcaJtSpePBfCsN+vmpreLTMOLGhCaiU7J2O09mOxiXjSk+UeMv4Y0Y5s0oFkXl GbOCAE/VqjTJEg54lNddWvbN1SLK9gV0vhVgJ+8MKGZFhV3ZI/HAlfHEPVW6fKOTj1SLBY QHXFGgy7DaFy5DgVDFO2QF5R+sidYMt2wgEyNZTl7/+4gbo6y+3YUojbbLxEoQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=disroot.org (policy=quarantine); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: 6.00 X-Spam: Yes Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=disroot.org (policy=quarantine); spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 135.181.149.255 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 771A83F03D X-Spam-Score: 6.00 X-Migadu-Spam: Yes X-Migadu-Scanner: scn1.migadu.com X-TUID: UTr0Ul7/N1ZL In the emacs client, calls to (notmuch-poll) are sychronous, which means that all of emacs hangs until notmuch new returns. I tried this little patch to make it asynchronous, and it seems to work fine. Three problems, though: a. notmuch-start-notmuch warns the user about everything, while notmuch-call-notmuch-process only warns on errors. b. notmuch-poll-and-refresh-this-buffer doesn't know that notmuch-poll is now asynchronous and so refreshes too early. c. The call to notmuch-poll-script is still synchronous, but that's a WIP. I think that the first two problems can be solved by a more sophisticated sentinel than the one I'm using here, but I'd love to hear other people's thoughts. Is there a reason that notmuch-poll is synchronous? Here's a diff from notmuch-lib.el: @@ -289,8 +289,11 @@ depending on the value of `notmuch-poll-script'." (unless (string-empty-p notmuch-poll-script) (unless (equal (notmuch--call-process notmuch-poll-script nil nil) 0) (error "Notmuch: poll script `%s' failed!" notmuch-poll-script))) - (notmuch-call-notmuch-process "new")) - (message "Polling mail...done")) + (notmuch-start-notmuch "poll" + nil + (lambda (proc string) + (message "Polling mail...done")) + "new"))) (defun notmuch-bury-or-kill-this-buffer () "Undisplay the current buffer.