bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#17815: 24.4.50; (process-file) erroneously raises its buffer when ru


From: Michael Albinus
Subject: bug#17815: 24.4.50; (process-file) erroneously raises its buffer when running with TRAMP
Date: Fri, 20 Jun 2014 15:50:48 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux)

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> @Stefan: This is no regression, I could reproduce it even with Emacs
>> 23.4. Therefore, I will fix it in the trunk. Please tell me if you
>> believe it shall go into emacs-24.
>
> Show me the patch (when it's ready), so I can see whether it looks
> safe enough.

That's what I've committed to the Tramp repository:

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 76a3c48..ba410f1 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
+2014-06-20  Michael Albinus  <michael.albinus@gmx.de>
+
+       * tramp-adb.el (tramp-adb-handle-process-file):
+       * tramp-sh.el (tramp-sh-handle-process-file):
+       * tramp-smb.el (tramp-smb-handle-process-file): Do not raise the
+       output buffer when DISPLAY is non-nil.  (Bug#17815)
+
 2014-06-16  Michael Albinus  <michael.albinus@gmx.de>

        * tramp.el (tramp-call-process): Handle error strings.
diff --git a/lisp/tramp-adb.el b/lisp/tramp-adb.el
index f38cecb..91caa4a 100644
--- a/lisp/tramp-adb.el
+++ b/lisp/tramp-adb.el
@@ -801,11 +801,11 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are 
completely ignored."
             v (format "(cd %s; %s)"
                       (tramp-shell-quote-argument localname) command)
             "")
-           ;; We should show the output anyway.
+           ;; We should add the output anyway.
            (when outbuf
              (with-current-buffer outbuf
                (insert-buffer-substring (tramp-get-connection-buffer v)))
-             (when display (display-buffer outbuf))))
+             (when (and display (get-buffer-window outbuf t)) (redisplay))))
        ;; When the user did interrupt, we should do it also.  We use
        ;; return code -1 as marker.
        (quit
diff --git a/lisp/tramp-sh.el b/lisp/tramp-sh.el
index a6771cd..68f1ef4 100644
--- a/lisp/tramp-sh.el
+++ b/lisp/tramp-sh.el
@@ -2994,13 +2994,13 @@ the result will be a local, non-Tramp, file name."
                                   command)
                         t t)
                        0 1))
-           ;; We should show the output anyway.
+           ;; We should add the output anyway.
            (when outbuf
              (with-current-buffer outbuf
                 (insert
                  (with-current-buffer (tramp-get-connection-buffer v)
                    (buffer-string))))
-             (when display (display-buffer outbuf))))
+             (when (and display (get-buffer-window outbuf t)) (redisplay))))
        ;; When the user did interrupt, we should do it also.  We use
        ;; return code -1 as marker.
        (quit
diff --git a/lisp/tramp-smb.el b/lisp/tramp-smb.el
index aa44b8d..15ae9ed 100644
--- a/lisp/tramp-smb.el
+++ b/lisp/tramp-smb.el
@@ -1225,8 +1225,8 @@ target of the symlink differ."
        (error
         (setq ret 1)))

-      ;; We should show the output anyway.
-      (when (and outbuf display) (display-buffer outbuf))
+      ;; We should redisplay the output.
+      (when (and display outbuf (get-buffer-window outbuf t)) (redisplay))

       ;; Cleanup.  We remove all file cache values for the connection,
       ;; because the remote process could have changed them.
diff --git a/test/ChangeLog b/test/ChangeLog
index c672532..5ba0b82 100644
--- a/test/ChangeLog
+++ b/test/ChangeLog
@@ -1,3 +1,8 @@
+2014-06-20  Michael Albinus  <michael.albinus@gmx.de>
+
+       * tramp-tests.el (tramp-test26-process-file): Extend test
+       according to Bug#17815.
+
 2014-06-15  Michael Albinus  <michael.albinus@gmx.de>

        Version 2.2.10 released.
diff --git a/test/tramp-tests.el b/test/tramp-tests.el
index d30a5b0..b010ab4 100644
--- a/test/tramp-tests.el
+++ b/test/tramp-tests.el
@@ -1246,9 +1246,10 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
      (tramp-find-foreign-file-name-handler tramp-test-temporary-file-directory)
      '(tramp-gvfs-file-name-handler tramp-smb-file-name-handler))))

-  (let ((tmp-name (tramp--test-make-temp-name))
-       (default-directory tramp-test-temporary-file-directory)
-       kill-buffer-query-functions)
+  (let* ((tmp-name (tramp--test-make-temp-name))
+        (fnnd (file-name-nondirectory tmp-name))
+        (default-directory tramp-test-temporary-file-directory)
+        kill-buffer-query-functions)
     (unwind-protect
        (progn
          ;; We cannot use "/bin/true" and "/bin/false"; those paths
@@ -1259,17 +1260,25 @@ This tests also `make-symbolic-link', `file-truename' 
and `add-name-to-file'."
          (with-temp-buffer
            (write-region "foo" nil tmp-name)
            (should (file-exists-p tmp-name))
-           (should
-            (zerop
-             (process-file "ls" nil t nil (file-name-nondirectory tmp-name))))
+           (should (zerop (process-file "ls" nil t nil fnnd)))
+           ;; `ls' could produce colorized output.
+           (goto-char (point-min))
+           (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
+             (replace-match "" nil nil))
+           (should (string-equal (format "%s\n" fnnd) (buffer-string)))
+           (should-not (get-buffer-window (current-buffer) t))
+
+           ;; Second run. The output must be appended.
+           (should (zerop (process-file "ls" nil t t fnnd)))
            ;; `ls' could produce colorized output.
            (goto-char (point-min))
            (while (re-search-forward tramp-color-escape-sequence-regexp nil t)
              (replace-match "" nil nil))
            (should
-            (string-equal
-             (format "%s\n" (file-name-nondirectory tmp-name))
-             (buffer-string)))))
+            (string-equal (format "%s\n%s\n" fnnd fnnd) (buffer-string)))
+           ;; A non-nil DISPLAY must not raise the buffer.
+           (should-not (get-buffer-window (current-buffer) t))))
+
       (ignore-errors (delete-file tmp-name)))))

 (ert-deftest tramp-test27-start-file-process ()
>         Stefan

Best regards, Michael.

reply via email to

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