[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: |
Stefan Monnier |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.4.50 (gnu/linux) |
> 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 ""))