From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id FD3iG+XeK2G1RQEAgWs5BA (envelope-from ) for ; Sun, 29 Aug 2021 21:24:21 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id uBudFuXeK2GNGwAAbx9fmQ (envelope-from ) for ; Sun, 29 Aug 2021 19:24:21 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (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 DFE0CD26A for ; Sun, 29 Aug 2021 21:24:16 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 821D91FB7C; Sun, 29 Aug 2021 15:23:58 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id 988BA1FB3E for ; Sun, 29 Aug 2021 15:23:53 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 91DAD5FD5C; Sun, 29 Aug 2021 15:23:53 -0400 (EDT) Received: (nullmailer pid 4192488 invoked by uid 1000); Sun, 29 Aug 2021 19:23:39 -0000 From: David Bremner To: David Bremner , Tomi Ollila , Matt Armstrong , notmuch@notmuchmail.org Subject: [PATCH 4/9] emacs: wrap call-process-region Date: Sun, 29 Aug 2021 12:23:30 -0700 Message-Id: <20210829192335.4192305-5-david@tethera.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210829192335.4192305-1-david@tethera.net> References: <87tvgqzq1o.fsf@tethera.net> <20210829192335.4192305-1-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: RD6VXGUPRAFSBW55OL5I3EF6XPCKKRU7 X-Message-ID-Hash: RD6VXGUPRAFSBW55OL5I3EF6XPCKKRU7 X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1630265057; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=roy2hV6RmsSrMBUrnd3hZW4ONfq0NNftS5zmEX59r7Q=; b=turfzbbxXQqrwrfU8cMdY54wouvmgL5NFkfX3pMeAcrpaFSa30hj+GSP2IEdyyXvBIu+uG Y1UDDnLengfDTscKSXUsZv0Xm2/vwD17lKn9UKhl60V3cFsHmgEOvp1vyP5LyB1X0iyT0f HKlXTRnbuOztKBIcuybRKCDqSHNYzI8u3LEqXOT1NFlXHotSbhlcGqmWVU/QKpuvs6WGaE udlPFtS6snfJXgIuOA8bGpbnoGsBGigl8SEQvheOUKfhwfBx+P492cvGlviuV8AI1D1T9Q y1RXI5lGTxDjQP/T3mJR9bf3BYNh3/vyC5CHAV7/ftMC0FWACLLeA+8ri/iHyQ== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630265057; a=rsa-sha256; cv=none; b=bfQ+gTOmbrDoex5yl7OZGw4+73S/6JwPE8ELktnbYC2f362IkhYBA9HmRa/wBSfiEl96tO +5njZXtCdLsZ5HrgIEmjeHICck9BnRcI98qyuBSvJnLiTNsk/b5JDyEUCUe02ZxJw9w3PP ZcMu47+uATdREAttxMAbQmk7SwQlCFKesHKaJ90f/scHxfEXXA5CuxhXXEBVdxekjuWZR4 ur/q0VEkK52mAqpEFbtJptmIoz32tdDakr8eLVyuU9sBV0KMcFwmvKdniOr3VCjr5VRTHU WdMOfUv4MBeGxP+XK2Z/IjGnNxeo3gnhXfKLCoazvWP4Mess0zVk2PzBYaN+eQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.05 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: DFE0CD26A X-Spam-Score: -1.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: I9xcpBRCoNjQ As with notmuch--process-lines, initial purpose is to provide a safe binding for default-directory. This is enough to make notmuch-hello robust against non-existent or corrupt values default-directory, but probably not other views. --- emacs/notmuch-hello.el | 2 +- emacs/notmuch-lib.el | 10 +++++++++- emacs/notmuch-print.el | 2 +- test/T440-emacs-hello.sh | 1 - 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 450cfcfb..30e6bd8e 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -567,7 +567,7 @@ options will be handled as specified for (or (plist-get options :filter-count) (plist-get options :filter)))) "\n"))) - (unless (= (call-process-region (point-min) (point-max) notmuch-command + (unless (= (notmuch--call-process-region (point-min) (point-max) notmuch-command t t nil "count" "--batch") 0) (notmuch-logged-error "notmuch count --batch failed" diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 928286c3..207ea4c2 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -869,6 +869,14 @@ You may need to restart Emacs or upgrade your notmuch package.")) default" (notmuch--apply-with-env #'process-lines program args)) +(defun notmuch--call-process-region (start end program + &optional delete buffer display + &rest args) + "Wrap call-process-region, binding DEFAULT-DIRECTORY to a safe +default" + (notmuch--apply-with-env + #'call-process-region start end program delete buffer display args)) + (defun notmuch-call-notmuch--helper (destination args) "Helper for synchronous notmuch invocation commands. @@ -885,7 +893,7 @@ for `call-process'. ARGS is as described for (if (null stdin-string) (apply #'call-process notmuch-command nil destination nil args) (insert stdin-string) - (apply #'call-process-region (point-min) (point-max) + (apply #'notmuch--call-process-region (point-min) (point-max) notmuch-command t destination nil args)))) (defun notmuch-call-notmuch-process (&rest args) diff --git a/emacs/notmuch-print.el b/emacs/notmuch-print.el index d0061499..85fa1f21 100644 --- a/emacs/notmuch-print.el +++ b/emacs/notmuch-print.el @@ -48,7 +48,7 @@ "Pass the contents of the current buffer to 'muttprint'. Optional OUTPUT allows passing a list of flags to muttprint." - (apply #'call-process-region (point-min) (point-max) + (apply #'notmuch--call-process-region (point-min) (point-max) ;; Reads from stdin. "muttprint" nil nil nil diff --git a/test/T440-emacs-hello.sh b/test/T440-emacs-hello.sh index 9d1e5a9c..a1ed1c2b 100755 --- a/test/T440-emacs-hello.sh +++ b/test/T440-emacs-hello.sh @@ -69,7 +69,6 @@ notmuch tag -$tag '*' test_expect_equal_file $EXPECTED/notmuch-hello-long-names OUTPUT test_begin_subtest "notmuch-hello with nonexistent CWD" -test_subtest_known_broken test_emacs ' (notmuch-hello) (test-log-error -- 2.33.0