]> git.eshelyaron.com Git - emacs.git/commitdiff
* net/tramp.el (tramp-handle-start-file-process): Protect
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 8 Dec 2010 20:07:25 +0000 (21:07 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 8 Dec 2010 20:07:25 +0000 (21:07 +0100)
buffer-modified value.  (Bug#7557)
(tramp-action-password): Delete region, do not narrow.
(tramp-process-actions): Do not widen.

lisp/ChangeLog
lisp/net/tramp.el

index a52a158f243fde61e32da3681c0a33df9988af71..814c5ef89fa7697012d54bfc2cac0e7bcc614147 100644 (file)
@@ -1,3 +1,10 @@
+2010-12-08  Michael Albinus  <michael.albinus@gmx.de>
+
+       * net/tramp.el (tramp-handle-start-file-process): Protect
+       buffer-modified value.  (Bug#7557)
+       (tramp-action-password): Delete region, do not narrow.
+       (tramp-process-actions): Do not widen.
+
 2010-12-08   Jan Moringen  <jmoringe@techfak.uni-bielefeld.de>
 
        * log-edit.el (log-edit-changelog-entries):
index a9733fc6a0fd4135abc2b998bd75c4565539484c..0b7bae6708230721fd88266aaafc3ddb593929e9 100644 (file)
@@ -4522,60 +4522,65 @@ beginning of local filename are not substituted."
 (defun tramp-handle-start-file-process (name buffer program &rest args)
   "Like `start-file-process' for Tramp files."
   (with-parsed-tramp-file-name default-directory nil
-    (unwind-protect
-       ;; When PROGRAM is nil, we just provide a tty.
-       (let ((command
-              (when (stringp program)
-                (format "cd %s; exec %s"
-                        (tramp-shell-quote-argument localname)
-                        (mapconcat 'tramp-shell-quote-argument
-                                   (cons program args) " "))))
-             (tramp-process-connection-type
-              (or (null program) tramp-process-connection-type))
-             (name1 name)
-             (i 0))
-         (unless buffer
-           ;; BUFFER can be nil.  We use a temporary buffer.
-           (setq buffer (generate-new-buffer tramp-temp-buffer-name)))
-         (while (get-process name1)
-           ;; NAME must be unique as process name.
-           (setq i (1+ i)
-                 name1 (format "%s<%d>" name i)))
-         (setq name name1)
-         ;; Set the new process properties.
-         (tramp-set-connection-property v "process-name" name)
-         (tramp-set-connection-property v "process-buffer" buffer)
-         ;; Activate narrowing in order to save BUFFER contents.
-         ;; Clear also the modification time; otherwise we might be
-         ;; interrupted by `verify-visited-file-modtime'.
-         (with-current-buffer (tramp-get-connection-buffer v)
-           (clear-visited-file-modtime)
-           (narrow-to-region (point-max) (point-max)))
-         (if command
-             ;; Send the command.
-             (tramp-send-command v command nil t) ; nooutput
-           ;; Check, whether a pty is associated.
-           (tramp-maybe-open-connection v)
-           (unless (process-get (tramp-get-connection-process v) 'remote-tty)
-             (tramp-error
-              v 'file-error "pty association is not supported for `%s'" name)))
-         (let ((p (tramp-get-connection-process v)))
-           ;; Set sentinel and query flag for this process.
-           (tramp-set-connection-property p "vector" v)
-           (set-process-sentinel p 'tramp-process-sentinel)
-           (tramp-set-process-query-on-exit-flag p t)
-           ;; Return process.
-           p))
-      ;; Save exit.
-      (with-current-buffer (tramp-get-connection-buffer v)
-       (if (string-match tramp-temp-buffer-name (buffer-name))
-           (progn
-             (set-process-buffer (tramp-get-connection-process v) nil)
-             (kill-buffer (current-buffer)))
-         (widen)
-         (goto-char (point-max))))
-      (tramp-set-connection-property v "process-name" nil)
-      (tramp-set-connection-property v "process-buffer" nil))))
+    ;; When PROGRAM is nil, we just provide a tty.
+    (let ((command
+          (when (stringp program)
+            (format "cd %s; exec %s"
+                    (tramp-shell-quote-argument localname)
+                    (mapconcat 'tramp-shell-quote-argument
+                               (cons program args) " "))))
+         (tramp-process-connection-type
+          (or (null program) tramp-process-connection-type))
+         (bmp (and (buffer-live-p buffer) (buffer-modified-p buffer)))
+         (name1 name)
+         (i 0))
+      (unwind-protect
+         (save-excursion
+           (save-restriction
+             (unless buffer
+               ;; BUFFER can be nil.  We use a temporary buffer.
+               (setq buffer (generate-new-buffer tramp-temp-buffer-name)))
+             (while (get-process name1)
+               ;; NAME must be unique as process name.
+               (setq i (1+ i)
+                     name1 (format "%s<%d>" name i)))
+             (setq name name1)
+             ;; Set the new process properties.
+             (tramp-set-connection-property v "process-name" name)
+             (tramp-set-connection-property v "process-buffer" buffer)
+             ;; Activate narrowing in order to save BUFFER contents.
+             ;; Clear also the modification time; otherwise we might
+             ;; be interrupted by `verify-visited-file-modtime'.
+             (with-current-buffer (tramp-get-connection-buffer v)
+               (let ((buffer-undo-list t))
+                 (clear-visited-file-modtime)
+                 (narrow-to-region (point-max) (point-max))
+                 (if command
+                     ;; Send the command.
+                     (tramp-send-command v command nil t) ; nooutput
+                   ;; Check, whether a pty is associated.
+                   (tramp-maybe-open-connection v)
+                   (unless (process-get
+                            (tramp-get-connection-process v) 'remote-tty)
+                     (tramp-error
+                      v 'file-error
+                      "pty association is not supported for `%s'" name)))))
+             (let ((p (tramp-get-connection-process v)))
+               ;; Set sentinel and query flag for this process.
+               (tramp-set-connection-property p "vector" v)
+               (set-process-sentinel p 'tramp-process-sentinel)
+               (tramp-set-process-query-on-exit-flag p t)
+               ;; Return process.
+               p)))
+       ;; Save exit.
+       (with-current-buffer (tramp-get-connection-buffer v)
+         (if (string-match tramp-temp-buffer-name (buffer-name))
+             (progn
+               (set-process-buffer (tramp-get-connection-process v) nil)
+               (kill-buffer (current-buffer)))
+           (set-buffer-modified-p bmp)))
+       (tramp-set-connection-property v "process-name" nil)
+       (tramp-set-connection-property v "process-buffer" nil)))))
 
 (defun tramp-handle-process-file
   (program &optional infile destination display &rest args)
@@ -6707,9 +6712,10 @@ file exists and nonzero exit status otherwise."
   (with-current-buffer (process-buffer proc)
     (tramp-check-for-regexp proc tramp-password-prompt-regexp)
     (tramp-message vec 3 "Sending %s" (match-string 1))
+    (tramp-message vec 6 "\n%s" (buffer-string)))
     (tramp-enter-password proc)
-    ;; Hide password prompt.
-    (narrow-to-region (point-max) (point-max))))
+    ;; Remove password prompt, in order not to find it next iteration.
+    (delete-region (point-min) (point-max)))
 
 (defun tramp-action-succeed (proc vec)
   "Signal success in finding shell prompt."
@@ -6820,7 +6826,6 @@ The terminal type can be configured with `tramp-terminal-type'."
                      (tramp-process-one-action proc vec actions))
                  (tramp-process-one-action proc vec actions)))))
       (with-current-buffer (tramp-get-connection-buffer vec)
-       (widen)
        (tramp-message vec 6 "\n%s" (buffer-string)))
       (unless (eq exit 'ok)
        (tramp-clear-passwd vec)