summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Bernoulli <jonas@bernoul.li>2016-08-12 23:55:00 +0200
committerJonas Bernoulli <jonas@bernoul.li>2016-08-12 23:55:00 +0200
commit07bb67b757a58da5a89e99cfc38bb449cd3edd6d (patch)
tree9152153a190a02737bbce0f4dd34b6f08af92692
parentd34824c06c3f625581a8c1dae15c04bc1478bb83 (diff)
remove with-editor-export-editor from hook for shell-command
Fixes #6.
-rw-r--r--with-editor.el49
1 files 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)