From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id CJgvEvTeK2EXRgEAgWs5BA (envelope-from ) for ; Sun, 29 Aug 2021 21:24:36 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id QN22DfTeK2F+PwAA1q6Kng (envelope-from ) for ; Sun, 29 Aug 2021 19:24:36 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [IPv6:2607:5300:201:3100::1657]) (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 BB47DD275 for ; Sun, 29 Aug 2021 21:24:35 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id 676A22051A; Sun, 29 Aug 2021 15:24:07 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [IPv6:2607:5300:60:c5::1]) by mail.notmuchmail.org (Postfix) with ESMTP id EBA3220500 for ; Sun, 29 Aug 2021 15:24:02 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id E3FC75FD5C; Sun, 29 Aug 2021 15:24:02 -0400 (EDT) Received: (nullmailer pid 4192485 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 3/9] emacs: wrap process-lines Date: Sun, 29 Aug 2021 12:23:29 -0700 Message-Id: <20210829192335.4192305-4-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: EGQFW3U6ALOXILC3WDSVXPG6VCKO62IX X-Message-ID-Hash: EGQFW3U6ALOXILC3WDSVXPG6VCKO62IX 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=1630265075; 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=+AgoIHbKlrSUIxMPyO9Yo3AC/NTXweGgKlHhHxHlGsY=; b=bAMAT+Li/yspegR+hZMRs7xKNSrNzyxm/2np7rw6m/N01zWb5SSJmWHpXBL+WNwun9gdTJ okDetwmzH992LFR0r21ZafAe+Nx/lvhpICY1E1ldxoATh4bRXqSasIcub6ucqqotMbMmrS m0U48A3/RtK0oIbiUmEC4Q4O7nGIIWWZhjYdmREXn9vrHg03BDCSzamn0/N2g+5m5XeUWv NbQtpXS92eMTFM9/v8t6kh58U1U3oxwxySSGTrhZh/K4ajpuU/fRsjOXho0sDfhxXPTzOH iyOpdbK2Q+IeSydOEl98r2AC+6Ypky23Cpmf0A+HMmJslPFJr8eTTlNCbFtWmw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1630265075; a=rsa-sha256; cv=none; b=kWL5c46CoMCgX/PhiEyx29bTn8lVSH5AonSxhVA0aIAUIXsSe6yhGVasPu5JgBcce3/tiW vhB8/l5Wa1E/aKo6dDnASFExmfAZsCNsDWtHQXXS6S7vFk5pcACkvpRFvxBRxFiO0kBNsP gbnZ7njmlxNURz3kxHu1qIzKwccEyB5o2FyKN8R90qFqmrx0y0TDwzIjzybUT4BF49PfLW ovFI7KAhHRty2N7E1RtsOEKDtJtWlq1r2KBBcM2MaYg7i8NFJ88hIU5sy7iBv+1zh/k4zD y/e0NFtCdTJ/b+Bz6Zyl1ga+XEAcbzYZCw06C12pTYmAinXSOQFl4v8D4E+F2g== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -0.99 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 2607:5300:201:3100::1657 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: BB47DD275 X-Spam-Score: -0.99 X-Migadu-Scanner: scn0.migadu.com X-TUID: 8Sy811wtEBoF Initially just set the working directory, to avoid (the implicit) call-process crashing when the default-directory points to a non-existent location. Use of a macro here is over-engineering for this change, but the same change needs to be applied to several other process creation primitives. --- emacs/notmuch-address.el | 2 +- emacs/notmuch-draft.el | 2 +- emacs/notmuch-hello.el | 6 +++--- emacs/notmuch-lib.el | 9 +++++++++ emacs/notmuch-tree.el | 2 +- emacs/notmuch.el | 2 +- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el index 9fc13bc5..1a4cdda2 100644 --- a/emacs/notmuch-address.el +++ b/emacs/notmuch-address.el @@ -217,7 +217,7 @@ requiring external commands." ;; harvest if necessary. (notmuch-address-harvest-trigger))) (t - (process-lines notmuch-address-command original)))) + (notmuch--process-lines notmuch-address-command original)))) (defun notmuch-address-expand-name () (cond diff --git a/emacs/notmuch-draft.el b/emacs/notmuch-draft.el index a68b7d8d..1f156746 100644 --- a/emacs/notmuch-draft.el +++ b/emacs/notmuch-draft.el @@ -239,7 +239,7 @@ applied to newly inserted messages)." (defun notmuch-draft-resume (id) "Resume editing of message with id ID." ;; Used by command `notmuch-show-resume-message'. - (let* ((tags (process-lines notmuch-command "search" "--output=tags" + (let* ((tags (notmuch--process-lines notmuch-command "search" "--output=tags" "--exclude=false" id)) (draft (equal tags (notmuch-update-tags tags notmuch-draft-tags)))) (when (or draft diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 1e66555b..450cfcfb 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -494,7 +494,7 @@ diagonal." (widget-get widget :notmuch-search-oldest-first))))) (defun notmuch-saved-search-count (search) - (car (process-lines notmuch-command "count" search))) + (car (notmuch--process-lines notmuch-command "count" search))) (defun notmuch-hello-tags-per-line (widest) "Determine how many tags to show per line and how wide they @@ -746,7 +746,7 @@ Complete list of currently available key bindings: (list (cons tag (concat "tag:" (notmuch-escape-boolean-term tag)))))) - (process-lines notmuch-command "search" "--output=tags" "*"))) + (notmuch--process-lines notmuch-command "search" "--output=tags" "*"))) (defun notmuch-hello-insert-header () "Insert the default notmuch-hello header." @@ -784,7 +784,7 @@ Complete list of currently available key bindings: :help-echo "Refresh" (notmuch-hello-nice-number (string-to-number - (car (process-lines notmuch-command "count"))))) + (car (notmuch--process-lines notmuch-command "count"))))) (widget-insert " messages.\n"))) (defun notmuch-hello-insert-saved-searches () diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index c7bb2091..928286c3 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -860,6 +860,15 @@ You may need to restart Emacs or upgrade your notmuch package.")) ;; `notmuch-logged-error' does not return. )))) +(defmacro notmuch--apply-with-env (func &rest args) + `(let ((default-directory "~")) + (apply ,func ,@args))) + +(defun notmuch--process-lines (program &rest args) + "Wrap process-lines, binding DEFAULT-DIRECTORY to a safe +default" + (notmuch--apply-with-env #'process-lines program args)) + (defun notmuch-call-notmuch--helper (destination args) "Helper for synchronous notmuch invocation commands. diff --git a/emacs/notmuch-tree.el b/emacs/notmuch-tree.el index 2f508128..49192e95 100644 --- a/emacs/notmuch-tree.el +++ b/emacs/notmuch-tree.el @@ -1098,7 +1098,7 @@ the same as for the function notmuch-tree." (concat " and (" query-context ")")))) (sort-arg (if oldest-first "--sort=oldest-first" "--sort=newest-first")) (message-arg (if unthreaded "--unthreaded" "--entire-thread"))) - (when (equal (car (process-lines notmuch-command "count" search-args)) "0") + (when (equal (car (notmuch--process-lines notmuch-command "count" search-args)) "0") (setq search-args basic-query)) (notmuch-tag-clear-cache) (let ((proc (notmuch-start-notmuch diff --git a/emacs/notmuch.el b/emacs/notmuch.el index 739cb93b..c81155e6 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -935,7 +935,7 @@ See `notmuch-tag' for information on the format of TAG-CHANGES." PROMPT is the string to prompt with." (let* ((all-tags (mapcar (lambda (tag) (notmuch-escape-boolean-term tag)) - (process-lines notmuch-command "search" "--output=tags" "*"))) + (notmuch--process-lines notmuch-command "search" "--output=tags" "*"))) (completions (append (list "folder:" "path:" "thread:" "id:" "date:" "from:" "to:" "subject:" "attachment:") -- 2.33.0