emacs-diffs
[Top][All Lists]
Advanced

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

[Emacs-diffs] /srv/bzr/emacs/trunk r105653: * net/tramp.el (top): Requir


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r105653: * net/tramp.el (top): Require 'shell. Use `tramp-unload-hook' but
Date: Sun, 04 Sep 2011 20:14:34 +0200
User-agent: Bazaar (2.3.1)

------------------------------------------------------------
revno: 105653
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Sun 2011-09-04 20:14:34 +0200
message:
  * net/tramp.el (top): Require 'shell.  Use `tramp-unload-hook' but
  `tramp-cache-unload-hook' where appropriate.
  (tramp-methods): Rename `tramp-remote-sh' to
  `tramp-remote-shell'.  Add `tramp-remote-shell-args'.
  (tramp-handle-shell-command): New defun, moved from tramp-sh.el.
  
  * net/tramp-sh.el (top): Don't require 'shell.
  (tramp-methods): Add `tramp-remote-shell' and
  `tramp-remote-shell-args' entries.
  (tramp-sh-file-name-handler-alist): Use `tramp-handle-shell-command'.
  (tramp-sh-handle-shell-command): Remove.
  (tramp-find-shell, tramp-open-connection-setup-interactive-shell):
  Use `tramp-remote-shell'.
modified:
  lisp/ChangeLog
  lisp/net/tramp-sh.el
  lisp/net/tramp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2011-09-03 20:24:12 +0000
+++ b/lisp/ChangeLog    2011-09-04 18:14:34 +0000
@@ -1,3 +1,19 @@
+2011-09-04  Michael Albinus  <address@hidden>
+
+       * net/tramp.el (top): Require 'shell.  Use `tramp-unload-hook' but
+       `tramp-cache-unload-hook' where appropriate.
+       (tramp-methods): Rename `tramp-remote-sh' to
+       `tramp-remote-shell'.  Add `tramp-remote-shell-args'.
+       (tramp-handle-shell-command): New defun, moved from tramp-sh.el.
+
+       * net/tramp-sh.el (top): Don't require 'shell.
+       (tramp-methods): Add `tramp-remote-shell' and
+       `tramp-remote-shell-args' entries.
+       (tramp-sh-file-name-handler-alist): Use `tramp-handle-shell-command'.
+       (tramp-sh-handle-shell-command): Remove.
+       (tramp-find-shell, tramp-open-connection-setup-interactive-shell):
+       Use `tramp-remote-shell'.
+
 2011-09-03  Chong Yidong  <address@hidden>
 
        * mail/sendmail.el (sendmail-query-once-function): Deleted.

=== modified file 'lisp/net/tramp-sh.el'
--- a/lisp/net/tramp-sh.el      2011-08-03 19:31:18 +0000
+++ b/lisp/net/tramp-sh.el      2011-09-04 18:14:34 +0000
@@ -28,7 +28,6 @@
 
 (eval-when-compile (require 'cl))      ; ignore-errors
 (require 'tramp)
-(require 'shell)
 
 ;; Pacify byte-compiler.  The function is needed on XEmacs only.  I'm
 ;; not sure at all that this is the right way to do it, but let's hope
@@ -91,7 +90,8 @@
   '("rcp"
     (tramp-login-program        "rsh")
     (tramp-login-args           (("%h") ("-l" "%u")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "rcp")
     (tramp-copy-args            (("-p" "%k") ("-r")))
     (tramp-copy-keep-date       t)
@@ -101,7 +101,8 @@
   '("remcp"
     (tramp-login-program        "remsh")
     (tramp-login-args           (("%h") ("-l" "%u")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "rcp")
     (tramp-copy-args            (("-p" "%k")))
     (tramp-copy-keep-date       t)))
@@ -111,7 +112,8 @@
    (tramp-login-program        "ssh")
    (tramp-login-args           (("-l" "%u") ("-p" "%p")        ("-e" "none") 
("%h")))
    (tramp-async-args           (("-q")))
-   (tramp-remote-sh            "/bin/sh")
+   (tramp-remote-shell         "/bin/sh")
+   (tramp-remote-shell-args    ("-c"))
    (tramp-copy-program         "scp")
    (tramp-copy-args            (("-P" "%p") ("-p" "%k")        ("-q") ("-r")))
    (tramp-copy-keep-date       t)
@@ -127,7 +129,8 @@
     (tramp-login-args           (("-l" "%u") ("-p" "%p")
                                 ("-1") ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "scp")
     (tramp-copy-args            (("-1") ("-P" "%p") ("-p" "%k") ("-q") ("-r")))
     (tramp-copy-keep-date       t)
@@ -143,7 +146,8 @@
     (tramp-login-args           (("-l" "%u") ("-p" "%p")
                                 ("-2") ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "scp")
     (tramp-copy-args            (("-2") ("-P" "%p") ("-p" "%k") ("-q") ("-r")))
     (tramp-copy-keep-date       t)
@@ -161,7 +165,8 @@
                                 ("-o" "ControlMaster=yes")
                                 ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "scp")
     (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q") ("-r")
                                 ("-o" "address@hidden:%%p")
@@ -180,7 +185,8 @@
                                 ("-e" "none") ("-t" "-t")
                                 ("%h") ("/bin/sh")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "scp")
     (tramp-copy-args            (("-P" "%p") ("-p" "%k") ("-q") ("-r")))
     (tramp-copy-keep-date       t)
@@ -195,7 +201,8 @@
     (tramp-login-program        "ssh")
     (tramp-login-args           (("-l" "%u") ("-p" "%p") ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "sftp")))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
@@ -203,7 +210,8 @@
     (tramp-login-program        "ssh")
     (tramp-login-args           (("-l" "%u") ("-p" "%p") ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "rsync")
     (tramp-copy-args            (("-e" "ssh") ("-t" "%k") ("-r")))
     (tramp-copy-keep-date       t)
@@ -218,7 +226,8 @@
                                 ("-o" "ControlMaster=yes")
                                 ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "rsync")
     (tramp-copy-args            (("-t" "%k") ("-r")))
     (tramp-copy-env             (("RSYNC_RSH")
@@ -234,20 +243,23 @@
   '("rsh"
     (tramp-login-program        "rsh")
     (tramp-login-args           (("%h") ("-l" "%u")))
-    (tramp-remote-sh            "/bin/sh")))
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
   '("remsh"
     (tramp-login-program        "remsh")
     (tramp-login-args           (("%h") ("-l" "%u")))
-    (tramp-remote-sh            "/bin/sh")))
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
   '("ssh"
     (tramp-login-program        "ssh")
     (tramp-login-args           (("-l" "%u") ("-p" "%p") ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
                                 ("-o" "UserKnownHostsFile=/dev/null")
                                 ("-o" "StrictHostKeyChecking=no")))
@@ -259,7 +271,8 @@
     (tramp-login-args           (("-l" "%u") ("-p" "%p")
                                 ("-1") ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
                                 ("-o" "UserKnownHostsFile=/dev/null")
                                 ("-o" "StrictHostKeyChecking=no")))
@@ -271,7 +284,8 @@
     (tramp-login-args           (("-l" "%u") ("-p" "%p")
                                 ("-2") ("-e" "none") ("%h")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
                                 ("-o" "UserKnownHostsFile=/dev/null")
                                 ("-o" "StrictHostKeyChecking=no")))
@@ -284,7 +298,8 @@
                                 ("-e" "none") ("-t" "-t")
                                 ("%h") ("/bin/sh")))
     (tramp-async-args           (("-q")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-gw-args              (("-o" "GlobalKnownHostsFile=/dev/null")
                                 ("-o" "UserKnownHostsFile=/dev/null")
                                 ("-o" "StrictHostKeyChecking=no")))
@@ -294,38 +309,44 @@
   '("telnet"
     (tramp-login-program        "telnet")
     (tramp-login-args           (("%h") ("%p")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-default-port         23)))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
   '("su"
     (tramp-login-program        "su")
     (tramp-login-args           (("-") ("%u")))
-    (tramp-remote-sh            "/bin/sh")))
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
   '("sudo"
     (tramp-login-program        "sudo")
     (tramp-login-args           (("-u" "%u") ("-s") ("-H") ("-p" "Password:")))
-    (tramp-remote-sh            "/bin/sh")))
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
   '("ksu"
     (tramp-login-program        "ksu")
     (tramp-login-args           (("%u") ("-q")))
-    (tramp-remote-sh            "/bin/sh")))
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
   '("krlogin"
     (tramp-login-program        "krlogin")
     (tramp-login-args           (("%h") ("-l" "%u") ("-x")))
-    (tramp-remote-sh            "/bin/sh")))
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
   '("plink"
     (tramp-login-program        "plink")
     (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%h")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-password-end-of-line "xy") ;see docstring for "xy"
     (tramp-default-port         22)))
 ;;;###tramp-autoload
@@ -333,7 +354,8 @@
   '("plink1"
     (tramp-login-program        "plink")
     (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-1" "-ssh") ("%h")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-password-end-of-line "xy") ;see docstring for "xy"
     (tramp-default-port         22)))
 ;;;###tramp-autoload
@@ -348,13 +370,15 @@
                                    tramp-terminal-type
                                    tramp-initial-end-of-output))
                                 ("/bin/sh")))
-    (tramp-remote-sh            "/bin/sh")))
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))))
 ;;;###tramp-autoload
 (add-to-list 'tramp-methods
   '("pscp"
     (tramp-login-program        "plink")
     (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%h")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "pscp")
     (tramp-copy-args            (("-P" "%p") ("-scp") ("-p" "%k")
                                 ("-q") ("-r")))
@@ -367,7 +391,8 @@
   '("psftp"
     (tramp-login-program        "plink")
     (tramp-login-args           (("-l" "%u") ("-P" "%p") ("-ssh") ("%h")))
-    (tramp-remote-sh            "/bin/sh")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-c"))
     (tramp-copy-program         "pscp")
     (tramp-copy-args            (("-P" "%p") ("-sftp") ("-p" "%k")
                                 ("-q") ("-r")))
@@ -379,7 +404,8 @@
   '("fcp"
     (tramp-login-program        "fsh")
     (tramp-login-args           (("%h") ("-l" "%u") ("sh" "-i")))
-    (tramp-remote-sh            "/bin/sh -i")
+    (tramp-remote-shell         "/bin/sh")
+    (tramp-remote-shell-args    ("-i") ("-c"))
     (tramp-copy-program         "fcp")
     (tramp-copy-args            (("-p" "%k")))
     (tramp-copy-keep-date       t)))
@@ -942,7 +968,7 @@
     (executable-find . tramp-sh-handle-executable-find)
     (start-file-process . tramp-sh-handle-start-file-process)
     (process-file . tramp-sh-handle-process-file)
-    (shell-command . tramp-sh-handle-shell-command)
+    (shell-command . tramp-handle-shell-command)
     (insert-directory . tramp-sh-handle-insert-directory)
     (expand-file-name . tramp-sh-handle-expand-file-name)
     (substitute-in-file-name . tramp-handle-substitute-in-file-name)
@@ -2853,7 +2879,7 @@
       ;; `process-file-side-effects' has been introduced with GNU
       ;; Emacs 23.2.  If set to `nil', no remote file will be changed
       ;; by `program'.  If it doesn't exist, we assume its default
-      ;; value 't'.
+      ;; value `t'.
       (unless (and (boundp 'process-file-side-effects)
                   (not (symbol-value 'process-file-side-effects)))
         (tramp-flush-directory-property v ""))
@@ -2873,87 +2899,6 @@
        (apply 'call-process program tmpfile buffer display args)
       (delete-file tmpfile))))
 
-(defun tramp-sh-handle-shell-command
-  (command &optional output-buffer error-buffer)
-  "Like `shell-command' for Tramp files."
-  (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
-        ;; We cannot use `shell-file-name' and `shell-command-switch',
-        ;; they are variables of the local host.
-        (args (list
-               (tramp-get-method-parameter
-                (tramp-file-name-method
-                 (tramp-dissect-file-name default-directory))
-                'tramp-remote-sh)
-               "-c" (substring command 0 asynchronous)))
-        current-buffer-p
-        (output-buffer
-         (cond
-          ((bufferp output-buffer) output-buffer)
-          ((stringp output-buffer) (get-buffer-create output-buffer))
-          (output-buffer
-           (setq current-buffer-p t)
-           (current-buffer))
-          (t (get-buffer-create
-              (if asynchronous
-                  "*Async Shell Command*"
-                "*Shell Command Output*")))))
-        (error-buffer
-         (cond
-          ((bufferp error-buffer) error-buffer)
-          ((stringp error-buffer) (get-buffer-create error-buffer))))
-        (buffer
-         (if (and (not asynchronous) error-buffer)
-             (with-parsed-tramp-file-name default-directory nil
-               (list output-buffer (tramp-make-tramp-temp-file v)))
-           output-buffer))
-        (p (get-buffer-process output-buffer)))
-
-    ;; Check whether there is another process running.  Tramp does not
-    ;; support 2 (asynchronous) processes in parallel.
-    (when p
-      (if (yes-or-no-p "A command is running.  Kill it? ")
-         (ignore-errors (kill-process p))
-       (error "Shell command in progress")))
-
-    (if current-buffer-p
-       (progn
-         (barf-if-buffer-read-only)
-         (push-mark nil t))
-      (with-current-buffer output-buffer
-       (setq buffer-read-only nil)
-       (erase-buffer)))
-
-    (if (and (not current-buffer-p) (integerp asynchronous))
-       (prog1
-           ;; Run the process.
-           (apply 'start-file-process "*Async Shell*" buffer args)
-         ;; Display output.
-         (pop-to-buffer output-buffer)
-         (setq mode-line-process '(":%s"))
-         (shell-mode))
-
-      (prog1
-         ;; Run the process.
-         (apply 'process-file (car args) nil buffer nil (cdr args))
-       ;; Insert error messages if they were separated.
-       (when (listp buffer)
-         (with-current-buffer error-buffer
-           (insert-file-contents (cadr buffer)))
-         (delete-file (cadr buffer)))
-       (if current-buffer-p
-           ;; This is like exchange-point-and-mark, but doesn't
-           ;; activate the mark.  It is cleaner to avoid activation,
-           ;; even though the command loop would deactivate the mark
-           ;; because we inserted text.
-           (goto-char (prog1 (mark t)
-                        (set-marker (mark-marker) (point)
-                                    (current-buffer))))
-         ;; There's some output, display it.
-         (when (with-current-buffer output-buffer (> (point-max) (point-min)))
-           (if (functionp 'display-message-or-buffer)
-               (tramp-compat-funcall 'display-message-or-buffer output-buffer)
-             (pop-to-buffer output-buffer))))))))
-
 (defun tramp-sh-handle-file-local-copy (filename)
   "Like `file-local-copy' for Tramp files."
   (with-parsed-tramp-file-name filename nil
@@ -3680,7 +3625,7 @@
             (tramp-set-connection-property
              vec "remote-shell"
              (tramp-get-method-parameter
-              (tramp-file-name-method vec) 'tramp-remote-sh)))))))))
+              (tramp-file-name-method vec) 'tramp-remote-shell)))))))))
 
 ;; Utility functions.
 
@@ -3716,7 +3661,8 @@
     ;; discarded as well.
     (tramp-open-shell
      vec
-     (tramp-get-method-parameter (tramp-file-name-method vec) 
'tramp-remote-sh))
+     (tramp-get-method-parameter
+      (tramp-file-name-method vec) 'tramp-remote-shell))
 
     ;; Disable echo.
     (tramp-message vec 5 "Setting up remote shell environment")

=== modified file 'lisp/net/tramp.el'
--- a/lisp/net/tramp.el 2011-08-31 08:18:20 +0000
+++ b/lisp/net/tramp.el 2011-09-04 18:14:34 +0000
@@ -58,6 +58,7 @@
 ;;; Code:
 
 (require 'tramp-compat)
+(require 'shell)
 
 ;;; User Customizable Internal Variables:
 
@@ -190,13 +191,16 @@
 This is a list of entries of the form (NAME PARAM1 PARAM2 ...).
 Each NAME stands for a remote access method.  Each PARAM is a
 pair of the form (KEY VALUE).  The following KEYs are defined:
-  * `tramp-remote-sh'
+  * `tramp-remote-shell'
     This specifies the Bourne shell to use on the remote host.  This
     MUST be a Bourne-like shell.  It is normally not necessary to set
     this to any value other than \"/bin/sh\": Tramp wants to use a shell
     which groks tilde expansion, but it can search for it.  Also note
     that \"/bin/sh\" exists on all Unixen, this might not be true for
     the value that you decide to use.  You Have Been Warned.
+  * `tramp-remote-shell-args'
+    For implementation of `shell-command', this specifies the
+    argument to let `tramp-remote-shell' run a command.
   * `tramp-login-program'
     This specifies the name of the program to use for logging in to the
     remote host.  This may be the name of rsh or a workalike program,
@@ -2959,6 +2963,92 @@
              (delete-file local-copy)))))
       t)))
 
+(defun tramp-handle-shell-command
+  (command &optional output-buffer error-buffer)
+  "Like `shell-command' for Tramp files."
+  (let* ((asynchronous (string-match "[ \t]*&[ \t]*\\'" command))
+        ;; We cannot use `shell-file-name' and `shell-command-switch',
+        ;; they are variables of the local host.
+        (args (append
+               (cons
+                (tramp-get-method-parameter
+                 (tramp-file-name-method
+                  (tramp-dissect-file-name default-directory))
+                 'tramp-remote-shell)
+                (tramp-get-method-parameter
+                 (tramp-file-name-method
+                  (tramp-dissect-file-name default-directory))
+                 'tramp-remote-shell-args))
+               (list (substring command 0 asynchronous))))
+        current-buffer-p
+        (output-buffer
+         (cond
+          ((bufferp output-buffer) output-buffer)
+          ((stringp output-buffer) (get-buffer-create output-buffer))
+          (output-buffer
+           (setq current-buffer-p t)
+           (current-buffer))
+          (t (get-buffer-create
+              (if asynchronous
+                  "*Async Shell Command*"
+                "*Shell Command Output*")))))
+        (error-buffer
+         (cond
+          ((bufferp error-buffer) error-buffer)
+          ((stringp error-buffer) (get-buffer-create error-buffer))))
+        (buffer
+         (if (and (not asynchronous) error-buffer)
+             (with-parsed-tramp-file-name default-directory nil
+               (list output-buffer (tramp-make-tramp-temp-file v)))
+           output-buffer))
+        (p (get-buffer-process output-buffer)))
+
+    ;; Check whether there is another process running.  Tramp does not
+    ;; support 2 (asynchronous) processes in parallel.
+    (when p
+      (if (yes-or-no-p "A command is running.  Kill it? ")
+         (ignore-errors (kill-process p))
+       (error "Shell command in progress")))
+
+    (if current-buffer-p
+       (progn
+         (barf-if-buffer-read-only)
+         (push-mark nil t))
+      (with-current-buffer output-buffer
+       (setq buffer-read-only nil)
+       (erase-buffer)))
+
+    (if (and (not current-buffer-p) (integerp asynchronous))
+       (prog1
+           ;; Run the process.
+           (apply 'start-file-process "*Async Shell*" buffer args)
+         ;; Display output.
+         (pop-to-buffer output-buffer)
+         (setq mode-line-process '(":%s"))
+         (shell-mode))
+
+      (prog1
+         ;; Run the process.
+         (apply 'process-file (car args) nil buffer nil (cdr args))
+       ;; Insert error messages if they were separated.
+       (when (listp buffer)
+         (with-current-buffer error-buffer
+           (insert-file-contents (cadr buffer)))
+         (delete-file (cadr buffer)))
+       (if current-buffer-p
+           ;; This is like exchange-point-and-mark, but doesn't
+           ;; activate the mark.  It is cleaner to avoid activation,
+           ;; even though the command loop would deactivate the mark
+           ;; because we inserted text.
+           (goto-char (prog1 (mark t)
+                        (set-marker (mark-marker) (point)
+                                    (current-buffer))))
+         ;; There's some output, display it.
+         (when (with-current-buffer output-buffer (> (point-max) (point-min)))
+           (if (functionp 'display-message-or-buffer)
+               (tramp-compat-funcall 'display-message-or-buffer output-buffer)
+             (pop-to-buffer output-buffer))))))))
+
 (defun tramp-handle-substitute-in-file-name (filename)
   "Like `substitute-in-file-name' for Tramp files.
 \"//\" and \"/~\" substitute only in the local filename part.
@@ -3477,7 +3567,7 @@
     (ignore-errors (delete-file tramp-temp-buffer-file-name))))
 
 (add-hook 'kill-buffer-hook 'tramp-delete-temp-file-function)
-(add-hook 'tramp-cache-unload-hook
+(add-hook 'tramp-unload-hook
          (lambda ()
            (remove-hook 'kill-buffer-hook
                         'tramp-delete-temp-file-function)))


reply via email to

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