unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>,
	Tomi Ollila <tomi.ollila@iki.fi>,
	Matt Armstrong <marmstrong@google.com>,
	notmuch@notmuchmail.org
Subject: [PATCH 4/9] emacs: wrap call-process-region
Date: Sun, 29 Aug 2021 12:23:30 -0700	[thread overview]
Message-ID: <20210829192335.4192305-5-david@tethera.net> (raw)
In-Reply-To: <20210829192335.4192305-1-david@tethera.net>

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

  parent reply	other threads:[~2021-08-29 19:24 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-17 21:03 [Joerg Jaspert] Bug#922536: notmuch-emacs: notmuch breaks on directory removal David Bremner
2019-02-18 22:18 ` Tomi Ollila
2019-02-20 18:12   ` Matt Armstrong
2019-02-21 17:18     ` Tomi Ollila
2019-02-26 12:34       ` David Bremner
2021-08-29 19:23         ` Wrap process creating primitives with safe CWD David Bremner
2021-08-29 19:23           ` [PATCH 1/9] test/emacs: provide macro test-log-error David Bremner
2021-08-29 19:23           ` [PATCH 2/9] test/emacs: run notmuch-hello with a nonexisting default dir David Bremner
2021-08-29 19:23           ` [PATCH 3/9] emacs: wrap process-lines David Bremner
2021-08-29 19:23           ` David Bremner [this message]
2021-08-29 19:23           ` [PATCH 5/9] test/emacs: test for notmuch-search with nonexistent CWD David Bremner
2021-08-29 19:23           ` [PATCH 6/9] emacs: wrap make-process David Bremner
2021-08-29 19:23           ` [PATCH 7/9] test/emacs: test for notmuch-show with nonexistent CWD David Bremner
2021-08-29 19:23           ` [PATCH 8/9] emacs: wrap call-process David Bremner
2021-08-29 19:23           ` [PATCH 9/9] test/emacs: tests for notmuch-{tree,unthreaded} with bad CWD David Bremner
2021-09-11 14:35           ` Wrap process creating primitives with safe CWD David Bremner
2021-09-11 14:49 ` [Joerg Jaspert] Bug#922536: notmuch-emacs: notmuch breaks on directory removal David Bremner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210829192335.4192305-5-david@tethera.net \
    --to=david@tethera.net \
    --cc=marmstrong@google.com \
    --cc=notmuch@notmuchmail.org \
    --cc=tomi.ollila@iki.fi \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).