]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: wrap call-process-region
authorDavid Bremner <david@tethera.net>
Sun, 29 Aug 2021 19:23:30 +0000 (12:23 -0700)
committerDavid Bremner <david@tethera.net>
Sat, 11 Sep 2021 13:19:27 +0000 (10:19 -0300)
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
emacs/notmuch-lib.el
emacs/notmuch-print.el
test/T440-emacs-hello.sh

index 61494c02635101da70220ce4837975a43a49090e..71487bd97b8795b71747594f98bcd54ed821a976 100644 (file)
@@ -569,7 +569,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"
index 928286c3292cbaf5a16715217a3f18c1819c7d9d..207ea4c21749ba295fc87d033f0ad1845b25f0e6 100644 (file)
@@ -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)
index d00614999147c100c4b94d472669d459cdbc6b2b..85fa1f218cfae1111cdb3e053c49cd4e05540b38 100644 (file)
@@ -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
index 9d1e5a9c2048d3d3b76b63b260fa53c6c4f65295..a1ed1c2b90ec7c821d6033a013ba44155a2296f1 100755 (executable)
@@ -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