From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id uJaqBtzeK2EvRAEAgWs5BA (envelope-from ) for ; Sun, 29 Aug 2021 21:24:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id yM9CAtzeK2GKBQAAB5/wlQ (envelope-from ) for ; Sun, 29 Aug 2021 19:24:12 +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)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 96B1B16ED9 for ; Sun, 29 Aug 2021 21:24:11 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 8A27A1FB90; Sun, 29 Aug 2021 15:23:55 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 876581FB6E for ; Sun, 29 Aug 2021 15:23:51 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 60D835FD5E; Sun, 29 Aug 2021 15:23:51 -0400 (EDT) Received: (nullmailer pid 4192501 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 8/9] emacs: wrap call-process Date: Sun, 29 Aug 2021 12:23:34 -0700 Message-Id: <20210829192335.4192305-9-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: 4TWKFCXMFZBRCA5F2JQMEURPW6CLZ4A4 X-Message-ID-Hash: 4TWKFCXMFZBRCA5F2JQMEURPW6CLZ4A4 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=1630265051; 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=tJgEnJDOJBaXbVHDc+/CDwQ7G/QaQVhcOfVHcELdWJs=; b=p+vDfY7drMY0tgdjhYQeVTpk+SSeDepdCw1w3KlPGT5KLbOf12EV9dUEjko/IvuQgjLw3Q QhiFouG9vlvUpeQO+J+jnivbSllr1QFRV4/DZdSNHPHVqPefiuf86XCr5tqqVGJfMhfIDR HMRpS2g2rQbRN0cHOT9bleACU1awEZjfJlsc1S8Gkcc8w0Q/GQb0pp94/MsxgUxtEgYEpL azD79T6rtuvHgl8VF2rueu0A2eEnOqJWucLdnjhrB8s+/oc3zRjrFkIMT9VcBOF/4rqxuN C/o9ewIZqiJZVozSes1h4yQjx2BzcGHJV+4nDxGC3Urxr8VVJAECa8qIOUXz9g== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630265051; a=rsa-sha256; cv=none; b=tmP2xW12XSegFqsXt05l+iPJlJlVWlJBjO/fWLlbNxWSD/ESuQ+vFE8eh6Kf+3n4VbSYPB 6OTL/Pnt6TuJj4mwyaoEmxrmQAaYkqaUDCu15tHgY4QHwfcwTxtRbB8XzdUppYo2Ml4Hiy iYlG02Du787EnSO8+zA4KR9drd+lCyQdooAPwT0eYu708bKCA3H+2SFk3wlBqnPGZK60fK k+FKQf8qFGt+FtKb4yTnctXNfy1Qyo1OrvYYhKkEU1KUgnVid0kzSaHkro3j5439LMraGY E6FZSSyL1J0NSYiPc/bVgTQZcutkgV7OiTuRv8qqAS8Z7JzKtjDPufcjMKvUBQ== 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: 96B1B16ED9 X-Spam-Score: -1.05 X-Migadu-Scanner: scn0.migadu.com X-TUID: XuVGkz9sJWDZ Provide a safe working directory --- emacs/notmuch-crypto.el | 6 +++--- emacs/notmuch-draft.el | 2 +- emacs/notmuch-lib.el | 14 +++++++++----- emacs/notmuch-mua.el | 2 +- emacs/notmuch-show.el | 6 +++--- emacs/notmuch-tag.el | 2 +- test/T450-emacs-show.sh | 1 - 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el index 3ffb5654..a1cf3ddd 100644 --- a/emacs/notmuch-crypto.el +++ b/emacs/notmuch-crypto.el @@ -164,7 +164,7 @@ mode." (goto-char (point-max)) (insert (format "-- Key %s in message %s:\n" fingerprint id)) - (call-process notmuch-crypto-gpg-program nil t t + (notmuch--call-process notmuch-crypto-gpg-program nil t t "--batch" "--no-tty" "--list-keys" fingerprint)) (recenter -1)))) @@ -240,9 +240,9 @@ corresponding key when the status button is pressed." (with-current-buffer buffer (goto-char (point-max)) (insert (format "--- Retrieving key %s:\n" keyid)) - (call-process notmuch-crypto-gpg-program nil t t "--recv-keys" keyid) + (notmuch--call-process notmuch-crypto-gpg-program nil t t "--recv-keys" keyid) (insert "\n") - (call-process notmuch-crypto-gpg-program nil t t "--list-keys" keyid)) + (notmuch--call-process notmuch-crypto-gpg-program nil t t "--list-keys" keyid)) (recenter -1)) (notmuch-show-refresh-view))))) diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el index 1f156746..d87a4805 100644 --- a/emacs/notmuch-draft.el +++ b/emacs/notmuch-draft.el @@ -249,7 +249,7 @@ applied to newly inserted messages)." (setq buffer-read-only nil) (erase-buffer) (let ((coding-system-for-read 'no-conversion)) - (call-process notmuch-command nil t nil "show" "--format=raw" id)) + (notmuch--call-process notmuch-command nil t nil "show" "--format=raw" id)) (mime-to-mml) (goto-char (point-min)) (when (re-search-forward "^$" nil t) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 9693185f..9afdc165 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -195,7 +195,7 @@ will be signaled. Otherwise the output will be returned." (with-temp-buffer - (let ((status (apply #'call-process notmuch-command nil t nil args)) + (let ((status (apply #'notmuch--call-process notmuch-command nil t nil args)) (output (buffer-string))) (notmuch-check-exit-status status (cons notmuch-command args) output) output))) @@ -206,7 +206,7 @@ Otherwise the output will be returned." (defun notmuch-cli-sane-p () "Return t if the cli seems to be configured sanely." (unless notmuch--cli-sane-p - (let ((status (call-process notmuch-command nil nil nil + (let ((status (notmuch--call-process notmuch-command nil nil nil "config" "get" "user.primary_email"))) (setq notmuch--cli-sane-p (= status 0)))) notmuch--cli-sane-p) @@ -286,7 +286,7 @@ depending on the value of `notmuch-poll-script'." (message "Polling mail...") (if (stringp notmuch-poll-script) (unless (string-empty-p notmuch-poll-script) - (unless (equal (call-process notmuch-poll-script nil nil) 0) + (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")) @@ -639,7 +639,7 @@ the given type." ;; charset is US-ASCII. RFC6657 ;; complicates this somewhat. 'us-ascii))))) - (apply #'call-process + (apply #'notmuch--call-process notmuch-command nil '(t nil) nil args) (buffer-string)))))) (when (and cache data) @@ -882,6 +882,10 @@ default" (notmuch--apply-with-env #'call-process-region start end program delete buffer display args)) +(defun notmuch--call-process (program &optional infile destination display &rest args) + (notmuch--apply-with-env + #'call-process program infile destination display args)) + (defun notmuch-call-notmuch--helper (destination args) "Helper for synchronous notmuch invocation commands. @@ -896,7 +900,7 @@ for `call-process'. ARGS is as described for (otherwise (error "Unknown keyword argument: %s" (car args))))) (if (null stdin-string) - (apply #'call-process notmuch-command nil destination nil args) + (apply #'notmuch--call-process notmuch-command nil destination nil args) (insert stdin-string) (apply #'notmuch--call-process-region (point-min) (point-max) notmuch-command t destination nil args)))) diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el index f510c043..c679373b 100644 --- a/emacs/notmuch-mua.el +++ b/emacs/notmuch-mua.el @@ -474,7 +474,7 @@ the From: address." (with-current-buffer temp-buffer (erase-buffer) (let ((coding-system-for-read 'no-conversion)) - (call-process notmuch-command nil t nil + (notmuch--call-process notmuch-command nil t nil "show" "--format=raw" id)) ;; Because we process the messages in reverse order, ;; always generate a forwarded subject, then use the diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 0f96c4fe..aea72e74 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -279,7 +279,7 @@ position of the message in the thread." (let ((buf (generate-new-buffer (concat "*notmuch-msg-" id "*")))) (with-current-buffer buf (let ((coding-system-for-read 'no-conversion)) - (call-process notmuch-command nil t nil "show" "--format=raw" id)) + (notmuch--call-process notmuch-command nil t nil "show" "--format=raw" id)) ,@body) (kill-buffer buf))))) @@ -2032,7 +2032,7 @@ to show, nil otherwise." (pop-to-buffer-same-window buf) (erase-buffer) (let ((coding-system-for-read 'no-conversion)) - (call-process notmuch-command nil t nil "show" "--format=raw" id)) + (notmuch--call-process notmuch-command nil t nil "show" "--format=raw" id)) (goto-char (point-min)) (set-buffer-modified-p nil) (setq buffer-read-only t) @@ -2083,7 +2083,7 @@ message." ;; Use the originating buffer's working directory instead of ;; that of the pipe buffer. (cd cwd) - (let ((exit-code (call-process-shell-command shell-command nil buf))) + (let ((exit-code (notmuch--call-process-shell-command shell-command nil buf))) (goto-char (point-max)) (set-buffer-modified-p nil) (setq buffer-read-only t) diff --git a/emacs/notmuch-tag.el b/emacs/notmuch-tag.el index ebccb5a0..6d9fc2f9 100644 --- a/emacs/notmuch-tag.el +++ b/emacs/notmuch-tag.el @@ -397,7 +397,7 @@ Return all tags if no search terms are given." (split-string (with-output-to-string (with-current-buffer standard-output - (apply 'call-process notmuch-command nil t + (apply 'notmuch--call-process notmuch-command nil t nil "search" "--output=tags" "--exclude=false" search-terms))) "\n+" t)) diff --git a/test/T450-emacs-show.sh b/test/T450-emacs-show.sh index 05e3692e..7cb142fa 100755 --- a/test/T450-emacs-show.sh +++ b/test/T450-emacs-show.sh @@ -232,7 +232,6 @@ test_expect_equal_file $EXPECTED/notmuch-show-decrypted-message-no-crypto OUTPUT test_begin_subtest "notmuch-show with nonexistent CWD" tid=$(notmuch search --limit=1 --output=threads '*' | sed s/thread://) -test_subtest_known_broken test_emacs "(test-log-error (let ((default-directory \"/nonexistent\")) (notmuch-show \"$tid\")))" -- 2.33.0