branch: elpa/with-editor
commit 89280a653f8cb6947d886f7cbd42de6d57838229
Author: Mario Rodas <[email protected]>
Commit: Jonas Bernoulli <[email protected]>

    with-editor-export-editor: Check whether there is a buffer process
    
    When `with-editor-export-editor' is added to the `shell-mode-hook', it's
    also executed by `shell-command', because it calls `shell-mode', which
    inherits from `comint-mode'.  Usually, `shell-command' is used to
    execute short-lived process, hence there might not be a process
    associated to the buffer when the hook is executed.
    
    The previous implementation assumed the existence of a process
    associated to a buffer, which might not be a case on `shell-command'
    buffers. This change intends to checks whether there is a process
    associated before sending the environment variables.
---
 with-editor.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/with-editor.el b/with-editor.el
index 9950fff..ed1841c 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -697,7 +697,7 @@ This works in `shell-mode', `term-mode', `eshell-mode' and
   (interactive (list (with-editor-read-envvar)))
   (cond
    ((derived-mode-p 'comint-mode 'term-mode)
-    (let ((process (get-buffer-process (current-buffer))))
+    (when-let ((process (get-buffer-process (current-buffer))))
       (goto-char (process-mark process))
       (process-send-string
        process (format " export %s=%s\n" envvar

Reply via email to