diff options
Diffstat (limited to 'lisp/net')
-rw-r--r-- | lisp/net/nsm.el | 2 | ||||
-rw-r--r-- | lisp/net/tramp-adb.el | 6 | ||||
-rw-r--r-- | lisp/net/tramp-sh.el | 162 | ||||
-rw-r--r-- | lisp/net/tramp.el | 24 | ||||
-rw-r--r-- | lisp/net/trampver.el | 6 |
5 files changed, 105 insertions, 95 deletions
diff --git a/lisp/net/nsm.el b/lisp/net/nsm.el index 3f3e7133713..0ce65a35ead 100644 --- a/lisp/net/nsm.el +++ b/lisp/net/nsm.el @@ -239,7 +239,7 @@ otherwise." (mapc (lambda (info) (let ((local-ip (nth 1 info)) - (mask (nth 2 info))) + (mask (nth 3 info))) (when (nsm-network-same-subnet (substring local-ip 0 -1) (substring mask 0 -1) diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el index c0c215de877..2c4ef2acaef 100644 --- a/lisp/net/tramp-adb.el +++ b/lisp/net/tramp-adb.el @@ -98,6 +98,7 @@ It is used for TCP/IP devices." `(,tramp-adb-method (tramp-login-program ,tramp-adb-program) (tramp-login-args (("shell"))) + (tramp-direct-async t) (tramp-tmpdir "/data/local/tmp") (tramp-default-port 5555))) @@ -895,8 +896,9 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored." ;; terminated. (defun tramp-adb-handle-make-process (&rest args) "Like `make-process' for Tramp files. -If connection property \"direct-async-process\" is non-nil, an -alternative implementation will be used." +If method parameter `tramp-direct-async' and connection property +\"direct-async-process\" are non-nil, an alternative +implementation will be used." (if (tramp-direct-async-process-p args) (apply #'tramp-handle-make-process args) (when args diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index b43b4485fec..e8ee372cb25 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -168,6 +168,7 @@ The string is used in `tramp-methods'.") (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) + (tramp-direct-async t) (tramp-remote-shell ,tramp-default-remote-shell) (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")) @@ -183,6 +184,7 @@ The string is used in `tramp-methods'.") ("-e" "none") ("-t" "-t") ("%h") ("%l"))) (tramp-async-args (("-q"))) + (tramp-direct-async t) (tramp-remote-shell ,tramp-default-remote-shell) (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")) @@ -197,6 +199,7 @@ The string is used in `tramp-methods'.") (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) + (tramp-direct-async t) (tramp-remote-shell ,tramp-default-remote-shell) (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")) @@ -227,6 +230,7 @@ The string is used in `tramp-methods'.") (tramp-login-args (("-l" "%u") ("-p" "%p") ("%c") ("-e" "none") ("%h"))) (tramp-async-args (("-q"))) + (tramp-direct-async t) (tramp-remote-shell ,tramp-default-remote-shell) (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")))) @@ -237,6 +241,7 @@ The string is used in `tramp-methods'.") ("-e" "none") ("-t" "-t") ("%h") ("%l"))) (tramp-async-args (("-q"))) + (tramp-direct-async t) (tramp-remote-shell ,tramp-default-remote-shell) (tramp-remote-shell-login ("-l")) (tramp-remote-shell-args ("-c")))) @@ -2601,7 +2606,7 @@ The method used must be an out-of-band method." (t nil))))))))) (defun tramp-sh-handle-insert-directory - (filename switches &optional wildcard full-directory-p) + (filename switches &optional wildcard full-directory-p) "Like `insert-directory' for Tramp files." (setq filename (expand-file-name filename)) (unless switches (setq switches "")) @@ -2636,66 +2641,63 @@ The method used must be an out-of-band method." v 4 "Inserting directory `ls %s %s', wildcard %s, fulldir %s" switches filename (if wildcard "yes" "no") (if full-directory-p "yes" "no")) - ;; If `full-directory-p', we just say `ls -l FILENAME'. - ;; Else we chdir to the parent directory, then say `ls -ld BASENAME'. + ;; If `full-directory-p', we just say `ls -l FILENAME'. Else we + ;; chdir to the parent directory, then say `ls -ld BASENAME'. (if full-directory-p (tramp-send-command - v - (format "%s %s %s 2>%s" - (tramp-get-ls-command v) - switches - (if wildcard - localname - (tramp-shell-quote-argument (concat localname "."))) - (tramp-get-remote-null-device v))) + v (format "%s %s %s 2>%s" + (tramp-get-ls-command v) + switches + (if wildcard + localname + (tramp-shell-quote-argument (concat localname "."))) + (tramp-get-remote-null-device v))) (tramp-barf-unless-okay - v - (format "cd %s" (tramp-shell-quote-argument - (tramp-run-real-handler - #'file-name-directory (list localname)))) + v (format "cd %s" (tramp-shell-quote-argument + (tramp-run-real-handler + #'file-name-directory (list localname)))) "Couldn't `cd %s'" (tramp-shell-quote-argument (tramp-run-real-handler #'file-name-directory (list localname)))) (tramp-send-command - v - (format "%s %s %s 2>%s" - (tramp-get-ls-command v) - switches - (if (or wildcard - (zerop (length - (tramp-run-real-handler - #'file-name-nondirectory (list localname))))) - "" - (tramp-shell-quote-argument - (tramp-run-real-handler - #'file-name-nondirectory (list localname)))) - (tramp-get-remote-null-device v)))) - - (save-restriction - (let ((beg (point)) - (emc enable-multibyte-characters)) - (narrow-to-region (point) (point)) - ;; We cannot use `insert-buffer-substring' because the Tramp - ;; buffer changes its contents before insertion due to calling - ;; `expand-file-name' and alike. - (insert - (with-current-buffer (tramp-get-buffer v) - (buffer-string))) - - ;; Check for "--dired" output. We must enable unibyte - ;; strings, because the "--dired" output counts in bytes. - (set-buffer-multibyte nil) + v (format "%s %s %s 2>%s" + (tramp-get-ls-command v) + switches + (if (or wildcard + (zerop (length + (tramp-run-real-handler + #'file-name-nondirectory (list localname))))) + "" + (tramp-shell-quote-argument + (tramp-run-real-handler + #'file-name-nondirectory (list localname)))) + (tramp-get-remote-null-device v)))) + + (let ((beg-marker (copy-marker (point) nil)) + (end-marker (copy-marker (point) t)) + (emc enable-multibyte-characters)) + ;; We cannot use `insert-buffer-substring' because the Tramp + ;; buffer changes its contents before insertion due to calling + ;; `expand-file-name' and alike. + (insert (with-current-buffer (tramp-get-buffer v) (buffer-string))) + + ;; We must enable unibyte strings, because the "--dired" + ;; output counts in bytes. + (set-buffer-multibyte nil) + (save-restriction + (narrow-to-region beg-marker end-marker) + ;; Check for "--dired" output. (forward-line -2) (when (looking-at-p "//SUBDIRED//") (forward-line -1)) (when (looking-at "//DIRED//\\s-+") - (let ((databeg (match-end 0)) + (let ((beg (match-end 0)) (end (point-at-eol))) ;; Now read the numeric positions of file names. - (goto-char databeg) + (goto-char beg) (while (< (point) end) - (let ((start (+ beg (read (current-buffer)))) - (end (+ beg (read (current-buffer))))) + (let ((start (+ (point-min) (read (current-buffer)))) + (end (+ (point-min) (read (current-buffer))))) (if (memq (char-after end) '(?\n ?\ )) ;; End is followed by \n or by " -> ". (put-text-property start end 'dired-filename t)))))) @@ -2703,18 +2705,18 @@ The method used must be an out-of-band method." (goto-char (point-at-bol)) (while (looking-at "//") (forward-line 1) - (delete-region (match-beginning 0) (point))) - ;; Reset multibyte if needed. - (set-buffer-multibyte emc) + (delete-region (match-beginning 0) (point)))) + ;; Reset multibyte if needed. + (set-buffer-multibyte emc) + (save-restriction + (narrow-to-region beg-marker end-marker) ;; Some busyboxes are reluctant to discard colors. (unless (string-match-p "color" (tramp-get-connection-property v "ls" "")) - (save-excursion - (goto-char beg) - (while - (re-search-forward tramp-display-escape-sequence-regexp nil t) - (replace-match "")))) + (goto-char (point-min)) + (while (re-search-forward tramp-display-escape-sequence-regexp nil t) + (replace-match ""))) ;; Now decode what read if necessary. Stolen from `insert-directory'. (let ((coding (or coding-system-for-read @@ -2729,36 +2731,32 @@ The method used must be an out-of-band method." ;; If no coding system is specified or detection is ;; requested, detect the coding. (if (eq (coding-system-base coding) 'undecided) - (setq coding (detect-coding-region beg (point) t))) - (if (not (eq (coding-system-base coding) 'undecided)) - (save-restriction - (setq coding-no-eol - (coding-system-change-eol-conversion coding 'unix)) - (narrow-to-region beg (point)) - (goto-char (point-min)) - (while (not (eobp)) - (setq pos (point) - val (get-text-property (point) 'dired-filename)) - (goto-char (next-single-property-change - (point) 'dired-filename nil (point-max))) - ;; Force no eol conversion on a file name, so - ;; that CR is preserved. - (decode-coding-region pos (point) - (if val coding-no-eol coding)) - (if val - (put-text-property pos (point) - 'dired-filename t))))))) + (setq coding (detect-coding-region (point-min) (point) t))) + (unless (eq (coding-system-base coding) 'undecided) + (setq coding-no-eol + (coding-system-change-eol-conversion coding 'unix)) + (goto-char (point-min)) + (while (not (eobp)) + (setq pos (point) + val (get-text-property (point) 'dired-filename)) + (goto-char (next-single-property-change + (point) 'dired-filename nil (point-max))) + ;; Force no eol conversion on a file name, so that + ;; CR is preserved. + (decode-coding-region + pos (point) (if val coding-no-eol coding)) + (if val (put-text-property pos (point) 'dired-filename t)))))) ;; The inserted file could be from somewhere else. (when (and (not wildcard) (not full-directory-p)) (goto-char (point-max)) (when (file-symlink-p filename) - (goto-char (search-backward "->" beg 'noerror))) + (goto-char (search-backward "->" (point-min) 'noerror))) (search-backward (if (directory-name-p filename) "." (file-name-nondirectory filename)) - beg 'noerror) + (point-min) 'noerror) (replace-match (file-relative-name filename) t)) ;; Try to insert the amount of free space. @@ -2769,9 +2767,11 @@ The method used must be an out-of-band method." ;; Replace "total" with "total used", to avoid confusion. (replace-match "\\1 used in directory") (end-of-line) - (insert " available " available))) + (insert " available " available)))) - (goto-char (point-max))))))) + (prog1 (goto-char end-marker) + (set-marker beg-marker nil) + (set-marker end-marker nil)))))) ;; Canonicalization of file names. @@ -2840,9 +2840,9 @@ the result will be a local, non-Tramp, file name." ;; terminated. (defun tramp-sh-handle-make-process (&rest args) "Like `make-process' for Tramp files. -STDERR can also be a file name. If connection property -\"direct-async-process\" is non-nil, an alternative -implementation will be used." +STDERR can also be a file name. If method parameter `tramp-direct-async' +and connection property \"direct-async-process\" are non-nil, an +alternative implementation will be used." (if (tramp-direct-async-process-p args) (apply #'tramp-handle-make-process args) (when args diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index cc8dda809e2..2816c58fe7f 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -259,9 +259,9 @@ pair of the form (KEY VALUE). The following KEYs are defined: parameters to suppress diagnostic messages, in order not to tamper the process output. - * `tramp-direct-async-args' - An additional argument when a direct asynchronous process is - started. Used so far only in the \"mock\" method of tramp-tests.el. + * `tramp-direct-async' + Whether the method supports direct asynchronous processes. + Until now, just \"ssh\"-based and \"adb\"-based methods do. * `tramp-copy-program' This specifies the name of the program to use for remotely copying @@ -1755,7 +1755,8 @@ The outline level is equal to the verbosity of the Tramp message." Message is formatted with FMT-STRING as control string and the remaining ARGUMENTS to actually emit the message (if applicable)." (let ((inhibit-message t) - file-name-handler-alist message-log-max signal-hook-function) + create-lockfiles file-name-handler-alist message-log-max + signal-hook-function) (with-current-buffer (tramp-get-debug-buffer vec) (goto-char (point-max)) (let ((point (point))) @@ -1982,6 +1983,13 @@ the resulting error message." (put #'tramp-with-demoted-errors 'tramp-suppress-trace t) +(defun tramp-test-message (fmt-string &rest arguments) + "Emit a Tramp message according `default-directory'." + (if (tramp-tramp-file-p default-directory) + (apply #'tramp-message + (tramp-dissect-file-name default-directory) 0 fmt-string arguments) + (apply #'message fmt-string arguments))) + ;; This function provides traces in case of errors not triggered by ;; Tramp functions. (defun tramp-signal-hook-function (error-symbol data) @@ -3741,7 +3749,9 @@ User is always nil." (let ((v (tramp-dissect-file-name default-directory)) (buffer (plist-get args :buffer)) (stderr (plist-get args :stderr))) - (and ;; It has been indicated. + (and ;; The method supports it. + (tramp-get-method-parameter v 'tramp-direct-async) + ;; It has been indicated. (tramp-get-connection-property v "direct-async-process" nil) ;; There's no multi-hop. (or (not (tramp-multi-hop-p v)) @@ -3821,8 +3831,6 @@ It does not support `:stderr'." (tramp-get-method-parameter v 'tramp-login-args)) (async-args (tramp-get-method-parameter v 'tramp-async-args)) - (direct-async-args - (tramp-get-method-parameter v 'tramp-direct-async-args)) ;; We don't create the temporary file. In fact, it ;; is just a prefix for the ControlPath option of ;; ssh; the real temporary file has another name, and @@ -3850,7 +3858,7 @@ It does not support `:stderr'." ?h (or host "") ?u (or user "") ?p (or port "") ?c options ?l "") ;; Add arguments for asynchronous processes. - login-args (append async-args direct-async-args login-args) + login-args (append async-args login-args) ;; Expand format spec. login-args (tramp-compat-flatten-tree diff --git a/lisp/net/trampver.el b/lisp/net/trampver.el index 714b3f9bb01..ced3e93fc09 100644 --- a/lisp/net/trampver.el +++ b/lisp/net/trampver.el @@ -7,7 +7,7 @@ ;; Maintainer: Michael Albinus <michael.albinus@gmx.de> ;; Keywords: comm, processes ;; Package: tramp -;; Version: 2.5.0 +;; Version: 2.5.1-pre ;; Package-Requires: ((emacs "25.1")) ;; Package-Type: multi ;; URL: https://www.gnu.org/software/tramp/ @@ -40,7 +40,7 @@ ;; ./configure" to change them. ;;;###tramp-autoload -(defconst tramp-version "2.5.0" +(defconst tramp-version "2.5.1-pre" "This version of Tramp.") ;;;###tramp-autoload @@ -76,7 +76,7 @@ ;; Check for Emacs version. (let ((x (if (not (string-lessp emacs-version "25.1")) "ok" - (format "Tramp 2.5.0 is not fit for %s" + (format "Tramp 2.5.1-pre is not fit for %s" (replace-regexp-in-string "\n" "" (emacs-version)))))) (unless (string-equal "ok" x) (error "%s" x))) |