aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/net/tramp.el73
1 files changed, 44 insertions, 29 deletions
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index 70d0fb070d8..a38b3c6e51c 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3621,8 +3621,13 @@ support symbolic links."
3621 (output-buffer-p output-buffer) 3621 (output-buffer-p output-buffer)
3622 (output-buffer 3622 (output-buffer
3623 (cond 3623 (cond
3624 ((bufferp output-buffer) output-buffer) 3624 ((bufferp output-buffer)
3625 ((stringp output-buffer) (get-buffer-create output-buffer)) 3625 (setq current-buffer-p (eq (current-buffer) output-buffer))
3626 output-buffer)
3627 ((stringp output-buffer)
3628 (setq current-buffer-p
3629 (eq (buffer-name (current-buffer)) output-buffer))
3630 (get-buffer-create output-buffer))
3626 (output-buffer 3631 (output-buffer
3627 (setq current-buffer-p t) 3632 (setq current-buffer-p t)
3628 (current-buffer)) 3633 (current-buffer))
@@ -3634,6 +3639,11 @@ support symbolic links."
3634 (cond 3639 (cond
3635 ((bufferp error-buffer) error-buffer) 3640 ((bufferp error-buffer) error-buffer)
3636 ((stringp error-buffer) (get-buffer-create error-buffer)))) 3641 ((stringp error-buffer) (get-buffer-create error-buffer))))
3642 (error-file
3643 (and error-buffer
3644 (with-parsed-tramp-file-name default-directory nil
3645 (tramp-make-tramp-file-name
3646 v (tramp-make-tramp-temp-file v)))))
3637 (bname (buffer-name output-buffer)) 3647 (bname (buffer-name output-buffer))
3638 (p (get-buffer-process output-buffer)) 3648 (p (get-buffer-process output-buffer))
3639 (dir default-directory) 3649 (dir default-directory)
@@ -3641,7 +3651,7 @@ support symbolic links."
3641 3651
3642 ;; The following code is taken from `shell-command', slightly 3652 ;; The following code is taken from `shell-command', slightly
3643 ;; adapted. Shouldn't it be factored out? 3653 ;; adapted. Shouldn't it be factored out?
3644 (when p 3654 (when (and (integerp asynchronous) p)
3645 (cond 3655 (cond
3646 ((eq async-shell-command-buffer 'confirm-kill-process) 3656 ((eq async-shell-command-buffer 'confirm-kill-process)
3647 ;; If will kill a process, query first. 3657 ;; If will kill a process, query first.
@@ -3677,22 +3687,21 @@ support symbolic links."
3677 (with-current-buffer output-buffer 3687 (with-current-buffer output-buffer
3678 (setq default-directory dir))) 3688 (setq default-directory dir)))
3679 3689
3680 (setq buffer (if error-buffer 3690 (setq buffer (if error-file (list output-buffer error-file) output-buffer))
3681 (with-parsed-tramp-file-name default-directory nil 3691
3682 (list output-buffer 3692 (with-current-buffer output-buffer
3683 (tramp-make-tramp-file-name 3693 (when current-buffer-p
3684 v (tramp-make-tramp-temp-file v)))) 3694 (barf-if-buffer-read-only)
3685 output-buffer)) 3695 (push-mark nil t))
3686 3696 ;; `shell-command-save-pos-or-erase' has been introduced with
3687 (if current-buffer-p 3697 ;; Emacs 27.1.
3688 (progn 3698 (if (fboundp 'shell-command-save-pos-or-erase)
3689 (barf-if-buffer-read-only) 3699 (tramp-compat-funcall
3690 (push-mark nil t)) 3700 'shell-command-save-pos-or-erase current-buffer-p)
3691 (with-current-buffer output-buffer
3692 (setq buffer-read-only nil) 3701 (setq buffer-read-only nil)
3693 (erase-buffer))) 3702 (erase-buffer)))
3694 3703
3695 (if (and (not current-buffer-p) (integerp asynchronous)) 3704 (if (integerp asynchronous)
3696 (let ((tramp-remote-process-environment 3705 (let ((tramp-remote-process-environment
3697 ;; `async-shell-command-width' has been introduced with 3706 ;; `async-shell-command-width' has been introduced with
3698 ;; Emacs 27.1. 3707 ;; Emacs 27.1.
@@ -3706,9 +3715,9 @@ support symbolic links."
3706 (setq p (start-file-process-shell-command 3715 (setq p (start-file-process-shell-command
3707 (buffer-name output-buffer) buffer command)) 3716 (buffer-name output-buffer) buffer command))
3708 ;; Insert error messages if they were separated. 3717 ;; Insert error messages if they were separated.
3709 (when (consp buffer) 3718 (when error-file
3710 (with-current-buffer error-buffer 3719 (with-current-buffer error-buffer
3711 (insert-file-contents-literally (cadr buffer)))) 3720 (insert-file-contents-literally error-file)))
3712 (if (process-live-p p) 3721 (if (process-live-p p)
3713 ;; Display output. 3722 ;; Display output.
3714 (with-current-buffer output-buffer 3723 (with-current-buffer output-buffer
@@ -3717,34 +3726,40 @@ support symbolic links."
3717 (shell-mode) 3726 (shell-mode)
3718 (set-process-filter p #'comint-output-filter) 3727 (set-process-filter p #'comint-output-filter)
3719 (set-process-sentinel p #'shell-command-sentinel) 3728 (set-process-sentinel p #'shell-command-sentinel)
3720 (when (consp buffer) 3729 (when error-file
3721 (add-function 3730 (add-function
3722 :after (process-sentinel p) 3731 :after (process-sentinel p)
3723 (lambda (_proc _string) 3732 (lambda (_proc _string)
3724 (with-current-buffer error-buffer 3733 (with-current-buffer error-buffer
3725 (insert-file-contents-literally 3734 (insert-file-contents-literally
3726 (cadr buffer) nil nil nil 'replace)) 3735 error-file nil nil nil 'replace))
3727 (delete-file (cadr buffer)))))) 3736 (delete-file error-file)))))
3728 3737
3729 (when (consp buffer) 3738 (when error-file
3730 (delete-file (cadr buffer)))))) 3739 (delete-file error-file)))))
3731 3740
3732 (prog1 3741 (prog1
3733 ;; Run the process. 3742 ;; Run the process.
3734 (process-file-shell-command command nil buffer nil) 3743 (process-file-shell-command command nil buffer nil)
3735 ;; Insert error messages if they were separated. 3744 ;; Insert error messages if they were separated.
3736 (when (consp buffer) 3745 (when error-file
3737 (with-current-buffer error-buffer 3746 (with-current-buffer error-buffer
3738 (insert-file-contents-literally (cadr buffer))) 3747 (insert-file-contents-literally error-file))
3739 (delete-file (cadr buffer))) 3748 (delete-file error-file))
3740 (if current-buffer-p 3749 (if current-buffer-p
3741 ;; This is like exchange-point-and-mark, but doesn't 3750 ;; This is like exchange-point-and-mark, but doesn't
3742 ;; activate the mark. It is cleaner to avoid activation, 3751 ;; activate the mark. It is cleaner to avoid activation,
3743 ;; even though the command loop would deactivate the mark 3752 ;; even though the command loop would deactivate the mark
3744 ;; because we inserted text. 3753 ;; because we inserted text.
3745 (goto-char (prog1 (mark t) 3754 (progn
3746 (set-marker (mark-marker) (point) 3755 (goto-char (prog1 (mark t)
3747 (current-buffer)))) 3756 (set-marker (mark-marker) (point)
3757 (current-buffer))))
3758 ;; `shell-command-set-point-after-cmd' has been
3759 ;; introduced with Emacs 27.1.
3760 (if (fboundp 'shell-command-set-point-after-cmd)
3761 (tramp-compat-funcall
3762 'shell-command-set-point-after-cmd)))
3748 ;; There's some output, display it. 3763 ;; There's some output, display it.
3749 (when (with-current-buffer output-buffer (> (point-max) (point-min))) 3764 (when (with-current-buffer output-buffer (> (point-max) (point-min)))
3750 (display-message-or-buffer output-buffer))))))) 3765 (display-message-or-buffer output-buffer)))))))