unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Michael Albinus <michael.albinus@gmx.de>
Cc: Dima Kogan <dima@secretsauce.net>, 17815-done@debbugs.gnu.org
Subject: bug#17815: 24.4.50; (process-file) erroneously raises its buffer when running with TRAMP
Date: Sun, 22 Jun 2014 08:55:43 -0400	[thread overview]
Message-ID: <jwvvbrthzu1.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <87ha3d47ka.fsf@gmx.de> (Michael Albinus's message of "Sun, 22 Jun 2014 11:28:21 +0200")

> Well, all handlers I could factor out for several backends, live in
> tramp.el as `tramp-handle-...'. `tramp-adb-handle-process-file' and
> `tramp-sh-handle-process-file' contain subtle differences, it will be
> harder to refactor them.

Those functions are almost 100 lines long and yet the diff between the
two is only the little thing below.  Clearly, there's room for a good
refactoring.  Maybe you can't replace them with a single function, but
you can create a third function that holds most of the code.


        Stefan


--- mine/tramp-sh.el
+++ other/tramp-sh.el
@@ -1,4 +1,4 @@
-(defun tramp-sh-handle-process-file
+(defun tramp-adb-handle-process-file
   (program &optional infile destination display &rest args)
   "Like `process-file' for Tramp files."
   ;; The implementation is not complete yet.
@@ -66,20 +66,16 @@
       ;; it.  Call it in a subshell, in order to preserve working
       ;; directory.
       (condition-case nil
-	  (unwind-protect
-              (setq ret
-		    (if (tramp-send-command-and-check
-			 v (format "\\cd %s; %s"
-				   (tramp-shell-quote-argument localname)
-				   command)
-			 t t)
-			0 1))
+	  (progn
+	    (setq ret 0)
+	    (tramp-adb-barf-unless-okay
+	     v (format "(cd %s; %s)"
+		       (tramp-shell-quote-argument localname) command)
+	     "")
 	    ;; We should add the output anyway.
 	    (when outbuf
 	      (with-current-buffer outbuf
-                (insert
-                 (with-current-buffer (tramp-get-connection-buffer v)
-                   (buffer-string))))
+		(insert-buffer-substring (tramp-get-connection-buffer v)))
 	      (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.
@@ -101,7 +97,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 ""))





  reply	other threads:[~2014-06-22 12:55 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-20  8:09 bug#17815: 24.4.50; (process-file) erroneously raises its buffer when running with TRAMP Dima Kogan
2014-06-20  8:32 ` Michael Albinus
2014-06-20 13:09   ` Stefan Monnier
2014-06-20 13:50     ` Michael Albinus
     [not found]       ` <jwvwqcbprk7.fsf-monnier+emacsbugs@gnu.org>
2014-06-22  9:28         ` Michael Albinus
2014-06-22 12:55           ` Stefan Monnier [this message]
2014-06-22 13:46             ` Michael Albinus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvvbrthzu1.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=17815-done@debbugs.gnu.org \
    --cc=dima@secretsauce.net \
    --cc=michael.albinus@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).