;; That's why we use `start-process'.
(let ((p (start-process
tramp-adb-program (current-buffer) tramp-adb-program "devices"))
- (v (tramp-make-tramp-file-name
- tramp-adb-method tramp-current-user nil
- tramp-current-host nil nil nil))
+ (v (make-tramp-file-name
+ :method tramp-adb-method :user tramp-current-user
+ :host tramp-current-host))
result)
(tramp-message v 6 "%s" (mapconcat 'identity (process-command p) " "))
(process-put p 'adjust-window-size-function 'ignore)
(tramp-flush-connection-property nil)
(with-tramp-connection-property (tramp-get-connection-process vec) "device"
(let* ((host (tramp-file-name-host vec))
- (port (tramp-file-name-port vec))
+ (port (tramp-file-name-port-or-default vec))
(devices (mapcar 'cadr (tramp-adb-parse-device-names nil))))
(replace-regexp-in-string
tramp-prefix-port-format ":"
(delete-process proc)
(tramp-error proc 'file-error "Process `%s' not available, try again" proc))
(with-current-buffer (process-buffer proc)
- (if (tramp-wait-for-regexp proc timeout tramp-adb-prompt)
+ (if (tramp-wait-for-regexp
+ proc timeout
+ (tramp-get-connection-property proc "prompt" tramp-adb-prompt))
(let (buffer-read-only)
(goto-char (point-min))
;; ADB terminal sends "^H" sequences.
(delete-region (point-min) (point)))
;; Delete the prompt.
(goto-char (point-min))
- (when (re-search-forward tramp-adb-prompt (point-at-eol) t)
+ (when (re-search-forward
+ (tramp-get-connection-property proc "prompt" tramp-adb-prompt)
+ (point-at-eol) t)
(forward-line 1)
(delete-region (point-min) (point)))
(goto-char (point-max))
- (re-search-backward tramp-adb-prompt nil t)
+ (re-search-backward
+ (tramp-get-connection-property proc "prompt" tramp-adb-prompt) nil t)
(delete-region (point) (point-max)))
(if timeout
(tramp-error
proc 'file-error
"[[Remote adb prompt `%s' not found in %d secs]]"
- tramp-adb-prompt timeout)
+ (tramp-get-connection-property proc "prompt" tramp-adb-prompt)
+ timeout)
(tramp-error
proc 'file-error
- "[[Remote prompt `%s' not found]]" tramp-adb-prompt)))))
+ "[[Remote prompt `%s' not found]]"
+ (tramp-get-connection-property proc "prompt" tramp-adb-prompt))))))
(defun tramp-adb-maybe-open-connection (vec)
"Maybe open a connection VEC.
(p (let ((default-directory
(tramp-compat-temporary-file-directory)))
(apply 'start-process (tramp-get-connection-name vec) buf
- tramp-adb-program args))))
+ tramp-adb-program args)))
+ (prompt (md5 (concat (prin1-to-string process-environment)
+ (current-time-string)))))
(tramp-message
vec 6 "%s" (mapconcat 'identity (process-command p) " "))
;; Wait for initial prompt.
(process-put p 'adjust-window-size-function 'ignore)
(set-process-query-on-exit-flag p nil)
+ ;; Change prompt.
+ (tramp-set-connection-property
+ p "prompt" (regexp-quote (format "///%s#$" prompt)))
+ (tramp-adb-send-command
+ vec (format "PS1=\"///\"\"%s\"\"#$\"" prompt))
+
;; Check whether the properties have been changed. If
;; yes, this is a strong indication that we must expire all
;; connection properties. We start again.
;; (substring-no-properties
;; (cl-struct-slot-value 'tramp-file-name slot key))))))
(dotimes (i (length key))
- (when (stringp (aref key i))
- (aset key i (substring-no-properties (aref key i))))))
+ (when (stringp (elt key i))
+ (setf (elt key i) (substring-no-properties (elt key i))))))
(when (stringp key)
(setq key (substring-no-properties key)))
(when (stringp value)
;; Remove temporary data. If there is the key "login-as", we
;; don't save either, because all other properties might
;; depend on the login name, and we want to give the
- ;; possibility to use another login name later on.
+ ;; possibility to use another login name later on. Key
+ ;; "started" exists for the "ftp" method only, which must be
+ ;; be kept persistent.
(maphash
(lambda (key value)
- (if (and (tramp-file-name-p key)
+ (if (and (tramp-file-name-p key) value
(not (tramp-file-name-localname key))
- (not (gethash "login-as" value)))
+ (not (gethash "login-as" value))
+ (not (gethash "started" value)))
(progn
(remhash "process-name" value)
(remhash "process-buffer" value)
"\\(" (tramp-method-regexp) "\\)" (tramp-postfix-method-regexp)
"\\(?:" "\\(" tramp-user-regexp "\\)" tramp-postfix-user-regexp "\\)?"
"\\(" "\\(?:" tramp-host-regexp "\\|"
- (tramp-prefix-ipv6-regexp) "\\(?:" tramp-ipv6-regexp "\\)?"
- (tramp-postfix-ipv6-regexp) "\\)"
+ (tramp-prefix-ipv6-regexp)
+ "\\(?:" tramp-ipv6-regexp "\\)?"
+ (tramp-postfix-ipv6-regexp) "\\)?"
"\\(?:" tramp-prefix-port-regexp tramp-port-regexp "\\)?" "\\)?"))
(defun tramp-file-name-structure ()
;; data structure.
;; The basic structure for remote file names. We use a list :type,
-;; otherwise the persistent data are not read in tramp-cache.el.
+;; in order to be compatible with Emacs 24 and 25.
(cl-defstruct (tramp-file-name (:type list) :named)
method user domain host port localname hop)
tramp-prefix-port-format)
(tramp-file-name-port vec))))
+(defun tramp-file-name-port-or-default (vec)
+ "Return port component of VEC.
+If nil, return `tramp-default-port'."
+ (or (tramp-file-name-port vec)
+ (tramp-get-method-parameter vec 'tramp-default-port)))
+
(defun tramp-file-name-equal-p (vec1 vec2)
"Check, whether VEC1 and VEC2 denote the same `tramp-file-name'."
(and (tramp-file-name-p vec1) (tramp-file-name-p vec2)
user (tramp-find-user method user host)
host (tramp-find-host method user host)))
- (apply
- 'make-tramp-file-name
- (append
- (unless (zerop (length method)) `(:method ,method))
- (unless (zerop (length user)) `(:user ,user))
- (unless (zerop (length domain)) `(:domain ,domain))
- (unless (zerop (length host)) `(:host ,host))
- (unless (zerop (length port)) `(:port ,port))
- `(:localname ,(or localname ""))
- (unless (zerop (length hop)) `(:hop ,hop))))))))
+ (make-tramp-file-name
+ :method method :user user :domain domain :host host :port port
+ :localname (or localname "") :hop hop)))))
(defun tramp-buffer-name (vec)
"A name for the connection buffer VEC."
;; There isn't. So we must check, in case there's a connection already.
(and (tramp-connectable-p filename)
(with-tramp-connection-property v "case-insensitive"
- ;; The idea is to compare a file with lower case letters
- ;; with the same file with upper case letters.
- (let ((candidate
- (tramp-compat-file-name-unquote
- (directory-file-name filename)))
- tmpfile)
- ;; Check, whether we find an existing file with lower case
- ;; letters. This avoids us to create a temporary file.
- (while (and (string-match
- "[a-z]" (file-remote-p candidate 'localname))
- (not (file-exists-p candidate)))
- (setq candidate
- (directory-file-name (file-name-directory candidate))))
- ;; Nothing found, so we must use a temporary file for
- ;; comparison. `make-nearby-temp-file' is added to
- ;; Emacs 26+ like `file-name-case-insensitive-p', so
- ;; there is no compatibility problem calling it.
- (unless
- (string-match "[a-z]" (file-remote-p candidate 'localname))
- (setq tmpfile
- (let ((default-directory (file-name-directory filename)))
- (tramp-compat-funcall 'make-nearby-temp-file "tramp."))
- candidate tmpfile))
- ;; Check for the existence of the same file with upper
- ;; case letters.
- (unwind-protect
- (file-exists-p
- (concat
- (file-remote-p candidate)
- (upcase (file-remote-p candidate 'localname))))
- ;; Cleanup.
- (when tmpfile (delete-file tmpfile)))))))))
+ (with-tramp-progress-reporter v 5 "Checking case-insensitive"
+ ;; The idea is to compare a file with lower case letters
+ ;; with the same file with upper case letters.
+ (let ((candidate
+ (tramp-compat-file-name-unquote
+ (directory-file-name filename)))
+ tmpfile)
+ ;; Check, whether we find an existing file with lower
+ ;; case letters. This avoids us to create a temporary
+ ;; file.
+ (while (and (string-match
+ "[a-z]" (file-remote-p candidate 'localname))
+ (not (file-exists-p candidate)))
+ (setq candidate
+ (directory-file-name (file-name-directory candidate))))
+ ;; Nothing found, so we must use a temporary file for
+ ;; comparison. `make-nearby-temp-file' is added to
+ ;; Emacs 26+ like `file-name-case-insensitive-p', so
+ ;; there is no compatibility problem calling it.
+ (unless
+ (string-match "[a-z]" (file-remote-p candidate 'localname))
+ (setq tmpfile
+ (let ((default-directory
+ (file-name-directory filename)))
+ (tramp-compat-funcall
+ 'make-nearby-temp-file "tramp."))
+ candidate tmpfile))
+ ;; Check for the existence of the same file with upper
+ ;; case letters.
+ (unwind-protect
+ (file-exists-p
+ (concat
+ (file-remote-p candidate)
+ (upcase (file-remote-p candidate 'localname))))
+ ;; Cleanup.
+ (when tmpfile (delete-file tmpfile))))))))))
(defun tramp-handle-file-name-completion
(filename directory &optional predicate)
are written with verbosity of 6."
(let ((default-directory (tramp-compat-temporary-file-directory))
(v (or vec
- (tramp-make-tramp-file-name
- tramp-current-method tramp-current-user tramp-current-domain
- tramp-current-host tramp-current-port nil nil)))
+ (make-tramp-file-name
+ :method tramp-current-method :user tramp-current-user
+ :domain tramp-current-domain :host tramp-current-host
+ :port tramp-current-port)))
(destination (if (eq destination t) (current-buffer) destination))
output error result)
(tramp-message
are written with verbosity of 6."
(let ((default-directory (tramp-compat-temporary-file-directory))
(v (or vec
- (tramp-make-tramp-file-name
- tramp-current-method tramp-current-user tramp-current-domain
- tramp-current-host tramp-current-port nil nil)))
+ (make-tramp-file-name
+ :method tramp-current-method :user tramp-current-user
+ :domain tramp-current-domain :host tramp-current-host
+ :port tramp-current-port)))
(buffer (if (eq buffer t) (current-buffer) buffer))
result)
(tramp-message