emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/with-editor 07bb67b 010/140: remove with-editor-export-edi


From: Jonas Bernoulli
Subject: [nongnu] elpa/with-editor 07bb67b 010/140: remove with-editor-export-editor from hook for shell-command
Date: Fri, 6 Aug 2021 12:51:10 -0400 (EDT)

branch: elpa/with-editor
commit 07bb67b757a58da5a89e99cfc38bb449cd3edd6d
Author: Jonas Bernoulli <jonas@bernoul.li>
Commit: Jonas Bernoulli <jonas@bernoul.li>

    remove with-editor-export-editor from hook for shell-command
    
    Fixes #6.
---
 with-editor.el | 49 ++++++++++++++++++++++++++++---------------------
 1 file changed, 28 insertions(+), 21 deletions(-)

diff --git a/with-editor.el b/with-editor.el
index 459b1c8..4730af6 100644
--- a/with-editor.el
+++ b/with-editor.el
@@ -637,27 +637,34 @@ else like the former."
 
 (defun shell-command--shell-command-with-editor-mode
     (fn command &optional output-buffer error-buffer)
-  (cond ((or (not (or with-editor--envvar shell-command-with-editor-mode))
-             (not (string-match-p "&\\'" command)))
-         (funcall fn command output-buffer error-buffer))
-        ((and with-editor-emacsclient-executable
-              (not (file-remote-p default-directory)))
-         (with-editor (funcall fn command output-buffer error-buffer)))
-        (t
-         (apply fn (format "%s=%s %s"
-                           (or with-editor--envvar "EDITOR")
-                           (shell-quote-argument with-editor-sleeping-editor)
-                           command)
-                output-buffer error-buffer)
-         (ignore-errors
-           (let ((process (get-buffer-process
-                           (or output-buffer
-                               (get-buffer "*Async Shell Command*")))))
-             (set-process-filter
-              process (lambda (proc str)
-                        (comint-output-filter proc str)
-                        (with-editor-process-filter proc str t)))
-             process)))))
+  ;; `shell-mode' and its hook are intended for buffers in which an
+  ;; interactive shell is running, but `shell-command' also turns on
+  ;; that mode, even though it only runs the shell to run a single
+  ;; command.  The `with-editor-export-editor' hook function is only
+  ;; intended to be used in buffers in which an interactive shell is
+  ;; running, so it has to be remove here.
+  (let ((shell-mode-hook (remove 'with-editor-export-editor shell-mode-hook)))
+    (cond ((or (not (or with-editor--envvar shell-command-with-editor-mode))
+               (not (string-match-p "&\\'" command)))
+           (funcall fn command output-buffer error-buffer))
+          ((and with-editor-emacsclient-executable
+                (not (file-remote-p default-directory)))
+           (with-editor (funcall fn command output-buffer error-buffer)))
+          (t
+           (apply fn (format "%s=%s %s"
+                             (or with-editor--envvar "EDITOR")
+                             (shell-quote-argument with-editor-sleeping-editor)
+                             command)
+                  output-buffer error-buffer)
+           (ignore-errors
+             (let ((process (get-buffer-process
+                             (or output-buffer
+                                 (get-buffer "*Async Shell Command*")))))
+               (set-process-filter
+                process (lambda (proc str)
+                          (comint-output-filter proc str)
+                          (with-editor-process-filter proc str t)))
+               process))))))
 
 (advice-add 'shell-command :around
             'shell-command--shell-command-with-editor-mode)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]