emacs: wrap make-process

Provide a safe working directory.
This commit is contained in:
David Bremner 2021-08-29 12:23:32 -07:00
parent 88224bde62
commit eb226437e1
3 changed files with 7 additions and 3 deletions

View file

@ -224,7 +224,7 @@ corresponding key when the status button is pressed."
(with-current-buffer buffer (with-current-buffer buffer
(goto-char (point-max)) (goto-char (point-max))
(insert (format "--- Retrieving key %s:\n" keyid))) (insert (format "--- Retrieving key %s:\n" keyid)))
(let ((p (make-process (let ((p (notmuch--make-process
:name "notmuch GPG key retrieval" :name "notmuch GPG key retrieval"
:connection-type 'pipe :connection-type 'pipe
:buffer buffer :buffer buffer

View file

@ -869,6 +869,11 @@ You may need to restart Emacs or upgrade your notmuch package."))
default" default"
(notmuch--apply-with-env #'process-lines program args)) (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 (defun notmuch--call-process-region (start end program
&optional delete buffer display &optional delete buffer display
&rest args) &rest args)
@ -950,7 +955,7 @@ status."
(let* ((command (or (executable-find notmuch-command) (let* ((command (or (executable-find notmuch-command)
(error "Command not found: %s" notmuch-command))) (error "Command not found: %s" notmuch-command)))
(err-buffer (generate-new-buffer " *notmuch-stderr*")) (err-buffer (generate-new-buffer " *notmuch-stderr*"))
(proc (make-process (proc (notmuch--make-process
:name name :name name
:buffer buffer :buffer buffer
:command (cons command args) :command (cons command args)

View file

@ -1169,7 +1169,6 @@ EOF
test_expect_equal_file EXPECTED OUTPUT test_expect_equal_file EXPECTED OUTPUT
test_begin_subtest "notmuch-search with nonexistent CWD" test_begin_subtest "notmuch-search with nonexistent CWD"
test_subtest_known_broken
test_emacs '(test-log-error test_emacs '(test-log-error
(let ((default-directory "/nonexistent")) (let ((default-directory "/nonexistent"))
(notmuch-search "*")))' (notmuch-search "*")))'