# HG changeset patch # User Andreas Schwab # Date 1218656016 0 # Node ID 8f3b361fa8c1b38c1a9df4ef77363c6b95003f3d # Parent 85c2adddd7659e746734005cff6677f04faa31ac (tramp-handle-shell-command): Handle output going to current buffer like shell-command. Don't disable undo. diff -r 85c2adddd765 -r 8f3b361fa8c1 lisp/ChangeLog --- a/lisp/ChangeLog Wed Aug 13 19:09:10 2008 +0000 +++ b/lisp/ChangeLog Wed Aug 13 19:33:36 2008 +0000 @@ -1,7 +1,7 @@ 2008-08-13 Andreas Schwab - * 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 diff -r 85c2adddd765 -r 8f3b361fa8c1 lisp/net/tramp.el --- a/lisp/net/tramp.el Wed Aug 13 19:09:10 2008 +0000 +++ b/lisp/net/tramp.el Wed Aug 13 19:33:36 2008 +0000 @@ -3878,7 +3878,10 @@ (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 @@ (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.