]> git.eshelyaron.com Git - emacs.git/commitdiff
(tramp-handle-shell-command): Handle output going
authorAndreas Schwab <schwab@suse.de>
Wed, 13 Aug 2008 19:33:36 +0000 (19:33 +0000)
committerAndreas Schwab <schwab@suse.de>
Wed, 13 Aug 2008 19:33:36 +0000 (19:33 +0000)
to current buffer like shell-command.  Don't disable undo.

lisp/ChangeLog
lisp/net/tramp.el

index 1401f4b8cd81abbe7ed9c9e52c63038e2e86c3a2..d2cd49750b286b24d2e5b16fb19dc432e4d4a31d 100644 (file)
@@ -1,7 +1,7 @@
 2008-08-13  Andreas Schwab  <schwab@suse.de>
 
-       * net/tramp.el (tramp-handle-shell-command): Correctly handle
-       output going to current buffer.  Don't disable undo.
+       * net/tramp.el (tramp-handle-shell-command): Handle output going
+       to current buffer like shell-command.  Don't disable undo.
 
 2008-08-13  Glenn Morris  <rgm@gnu.org>
 
index 67e679b2ef36ffd31d08aa6d0c39256e011a9381..828c1d2442f5338659e515751bca06b095300407 100644 (file)
@@ -3878,7 +3878,10 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
            (error nil))
        (error "Shell command in progress")))
 
-    (unless current-buffer-p
+    (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)))
@@ -3900,12 +3903,20 @@ Lisp error raised when PROGRAM is nil is trapped also, returning 1."
          (with-current-buffer error-buffer
            (insert-file-contents (cadr buffer)))
          (delete-file (cadr buffer)))
-       ;; There's some output, display it.
-       (when (with-current-buffer output-buffer (> (point-max) (point-min)))
-         (if (functionp 'display-message-or-buffer)
-             (funcall (symbol-function 'display-message-or-buffer)
-                      output-buffer)
-           (pop-to-buffer output-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)
+               (funcall (symbol-function 'display-message-or-buffer)
+                        output-buffer)
+             (pop-to-buffer output-buffer))))))))
 
 ;; File Editing.