From eb226437e1c0da6da86c04c78cbdd2020b982ad6 Mon Sep 17 00:00:00 2001 From: David Bremner Date: Sun, 29 Aug 2021 12:23:32 -0700 Subject: [PATCH] emacs: wrap make-process Provide a safe working directory. --- emacs/notmuch-crypto.el | 2 +- emacs/notmuch-lib.el | 7 ++++++- test/T310-emacs.sh | 1 - 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/emacs/notmuch-crypto.el b/emacs/notmuch-crypto.el index de4d9aea..3ffb5654 100644 --- a/emacs/notmuch-crypto.el +++ b/emacs/notmuch-crypto.el @@ -224,7 +224,7 @@ corresponding key when the status button is pressed." (with-current-buffer buffer (goto-char (point-max)) (insert (format "--- Retrieving key %s:\n" keyid))) - (let ((p (make-process + (let ((p (notmuch--make-process :name "notmuch GPG key retrieval" :connection-type 'pipe :buffer buffer diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 207ea4c2..9693185f 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -869,6 +869,11 @@ You may need to restart Emacs or upgrade your notmuch package.")) default" (notmuch--apply-with-env #'process-lines program args)) +(defun notmuch--make-process (&rest args) + "Wrap make-process, binding DEFAULT-DIRECTORY to a safe +default" + (notmuch--apply-with-env #'make-process args)) + (defun notmuch--call-process-region (start end program &optional delete buffer display &rest args) @@ -950,7 +955,7 @@ status." (let* ((command (or (executable-find notmuch-command) (error "Command not found: %s" notmuch-command))) (err-buffer (generate-new-buffer " *notmuch-stderr*")) - (proc (make-process + (proc (notmuch--make-process :name name :buffer buffer :command (cons command args) diff --git a/test/T310-emacs.sh b/test/T310-emacs.sh index 21b73e5a..1b6660f0 100755 --- a/test/T310-emacs.sh +++ b/test/T310-emacs.sh @@ -1169,7 +1169,6 @@ EOF test_expect_equal_file EXPECTED OUTPUT test_begin_subtest "notmuch-search with nonexistent CWD" -test_subtest_known_broken test_emacs '(test-log-error (let ((default-directory "/nonexistent")) (notmuch-search "*")))' -- 2.43.0