1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00

Tramp code cleanup

* lisp/net/tramp.el (tramp-remote-path): Adapt docstring.
(tramp-action-login, tramp-action-password, tramp-action-yesno)
(tramp-action-yn, tramp-process-actions): Move let-binding of
`enable-recursive-minibuffers' up.
(tramp-handle-make-process, tramp-handle-write-region):
* lisp/net/tramp-adb.el (tramp-adb-handle-write-region)
(tramp-adb-handle-make-process):
* lisp/net/tramp-sh.el (tramp-sh-handle-make-process)
(tramp-sh-handle-write-region):
* lisp/net/tramp-smb.el (tramp-smb-handle-write-region):
* lisp/net/tramp-sshfs.el (tramp-sshfs-handle-write-region):
Use `string-or-null-p'.
This commit is contained in:
Michael Albinus 2021-10-09 18:42:11 +02:00
parent 394209c1a0
commit 75d9fbec88
5 changed files with 36 additions and 39 deletions

View File

@ -600,7 +600,7 @@ But handle the case, if the \"test\" command is not available."
;; The end. ;; The end.
(when (and (null noninteractive) (when (and (null noninteractive)
(or (eq visit t) (null visit) (stringp visit))) (or (eq visit t) (string-or-null-p visit)))
(tramp-message v 0 "Wrote %s" filename)) (tramp-message v 0 "Wrote %s" filename))
(run-hooks 'tramp-handle-write-region-hook)))) (run-hooks 'tramp-handle-write-region-hook))))
@ -933,8 +933,8 @@ implementation will be used."
(stderr (plist-get args :stderr))) (stderr (plist-get args :stderr)))
(unless (stringp name) (unless (stringp name)
(signal 'wrong-type-argument (list #'stringp name))) (signal 'wrong-type-argument (list #'stringp name)))
(unless (or (null buffer) (bufferp buffer) (stringp buffer)) (unless (or (bufferp buffer) (string-or-null-p buffer))
(signal 'wrong-type-argument (list #'stringp buffer))) (signal 'wrong-type-argument (list #'bufferp buffer)))
(unless (consp command) (unless (consp command)
(signal 'wrong-type-argument (list #'consp command))) (signal 'wrong-type-argument (list #'consp command)))
(unless (or (null coding) (unless (or (null coding)
@ -951,7 +951,7 @@ implementation will be used."
(signal 'wrong-type-argument (list #'functionp filter))) (signal 'wrong-type-argument (list #'functionp filter)))
(unless (or (null sentinel) (functionp sentinel)) (unless (or (null sentinel) (functionp sentinel))
(signal 'wrong-type-argument (list #'functionp sentinel))) (signal 'wrong-type-argument (list #'functionp sentinel)))
(unless (or (null stderr) (bufferp stderr) (stringp stderr)) (unless (or (bufferp stderr) (string-or-null-p stderr))
(signal 'wrong-type-argument (list #'bufferp stderr))) (signal 'wrong-type-argument (list #'bufferp stderr)))
(when (and (stringp stderr) (tramp-tramp-file-p stderr) (when (and (stringp stderr) (tramp-tramp-file-p stderr)
(not (tramp-equal-remote default-directory stderr))) (not (tramp-equal-remote default-directory stderr)))

View File

@ -2771,8 +2771,8 @@ implementation will be used."
(stderr (plist-get args :stderr))) (stderr (plist-get args :stderr)))
(unless (stringp name) (unless (stringp name)
(signal 'wrong-type-argument (list #'stringp name))) (signal 'wrong-type-argument (list #'stringp name)))
(unless (or (null buffer) (bufferp buffer) (stringp buffer)) (unless (or (bufferp buffer) (string-or-null-p buffer))
(signal 'wrong-type-argument (list #'stringp buffer))) (signal 'wrong-type-argument (list #'bufferp buffer)))
(unless (or (null command) (consp command)) (unless (or (null command) (consp command))
(signal 'wrong-type-argument (list #'consp command))) (signal 'wrong-type-argument (list #'consp command)))
(unless (or (null coding) (unless (or (null coding)
@ -2789,7 +2789,7 @@ implementation will be used."
(signal 'wrong-type-argument (list #'functionp filter))) (signal 'wrong-type-argument (list #'functionp filter)))
(unless (or (null sentinel) (functionp sentinel)) (unless (or (null sentinel) (functionp sentinel))
(signal 'wrong-type-argument (list #'functionp sentinel))) (signal 'wrong-type-argument (list #'functionp sentinel)))
(unless (or (null stderr) (bufferp stderr) (stringp stderr)) (unless (or (bufferp stderr) (string-or-null-p stderr))
(signal 'wrong-type-argument (list #'bufferp stderr))) (signal 'wrong-type-argument (list #'bufferp stderr)))
(when (and (stringp stderr) (when (and (stringp stderr)
(not (tramp-equal-remote default-directory stderr))) (not (tramp-equal-remote default-directory stderr)))
@ -3513,7 +3513,7 @@ implementation will be used."
(tramp-compat-funcall 'unlock-file lockname)) (tramp-compat-funcall 'unlock-file lockname))
(when (and (null noninteractive) (when (and (null noninteractive)
(or (eq visit t) (null visit) (stringp visit))) (or (eq visit t) (string-or-null-p visit)))
(tramp-message v 0 "Wrote %s" filename)) (tramp-message v 0 "Wrote %s" filename))
(run-hooks 'tramp-handle-write-region-hook))))) (run-hooks 'tramp-handle-write-region-hook)))))

View File

@ -1658,7 +1658,7 @@ errors for shares like \"C$/\", which are common in Microsoft Windows."
;; The end. ;; The end.
(when (and (null noninteractive) (when (and (null noninteractive)
(or (eq visit t) (null visit) (stringp visit))) (or (eq visit t) (string-or-null-p visit)))
(tramp-message v 0 "Wrote %s" filename)) (tramp-message v 0 "Wrote %s" filename))
(run-hooks 'tramp-handle-write-region-hook)))) (run-hooks 'tramp-handle-write-region-hook))))

View File

@ -320,7 +320,7 @@ arguments to pass to the OPERATION."
;; The end. ;; The end.
(when (and (null noninteractive) (when (and (null noninteractive)
(or (eq visit t) (null visit) (stringp visit))) (or (eq visit t) (string-or-null-p visit)))
(tramp-message v 0 "Wrote %s" filename)) (tramp-message v 0 "Wrote %s" filename))
(run-hooks 'tramp-handle-write-region-hook)))) (run-hooks 'tramp-handle-write-region-hook))))

View File

@ -1304,7 +1304,7 @@ let-bind this variable."
;; "getconf PATH" yields: ;; "getconf PATH" yields:
;; HP-UX: /usr/bin:/usr/ccs/bin:/opt/ansic/bin:/opt/langtools/bin:/opt/fortran/bin ;; HP-UX: /usr/bin:/usr/ccs/bin:/opt/ansic/bin:/opt/langtools/bin:/opt/fortran/bin
;; Solaris: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin ;; Solaris: /usr/xpg4/bin:/usr/ccs/bin:/usr/bin:/opt/SUNWspro/bin
;; GNU/Linux (Debian, Suse, RHEL): /bin:/usr/bin ;; GNU/Linux (Debian, Suse, RHEL, Cygwin, MINGW64): /bin:/usr/bin
;; FreeBSD, DragonFly: /usr/bin:/bin:/usr/sbin:/sbin: - beware trailing ":"! ;; FreeBSD, DragonFly: /usr/bin:/bin:/usr/sbin:/sbin: - beware trailing ":"!
;; FreeBSD 12.1, Darwin: /usr/bin:/bin:/usr/sbin:/sbin ;; FreeBSD 12.1, Darwin: /usr/bin:/bin:/usr/sbin:/sbin
;; IRIX64: /usr/bin ;; IRIX64: /usr/bin
@ -1326,9 +1326,9 @@ tilde expansion, all directory names starting with \"~\" will be ignored.
the command \"getconf PATH\". It is recommended to use this the command \"getconf PATH\". It is recommended to use this
entry on head of this list, because these are the default entry on head of this list, because these are the default
directories for POSIX compatible commands. On remote hosts which directories for POSIX compatible commands. On remote hosts which
do not offer the getconf command (like cygwin), the value do not offer the getconf command, the value \"/bin:/usr/bin\" is
\"/bin:/usr/bin\" is used instead. This entry is represented in used instead. This entry is represented in the list by the
the list by the special value `tramp-default-remote-path'. special value `tramp-default-remote-path'.
`Private Directories' are the settings of the $PATH environment, `Private Directories' are the settings of the $PATH environment,
as given in your `~/.profile'. This entry is represented in as given in your `~/.profile'. This entry is represented in
@ -4127,8 +4127,8 @@ substitution. SPEC-LIST is a list of char/value pairs used for
(stderr (plist-get args :stderr))) (stderr (plist-get args :stderr)))
(unless (stringp name) (unless (stringp name)
(signal 'wrong-type-argument (list #'stringp name))) (signal 'wrong-type-argument (list #'stringp name)))
(unless (or (null buffer) (bufferp buffer) (stringp buffer)) (unless (or (bufferp buffer) (string-or-null-p buffer))
(signal 'wrong-type-argument (list #'stringp buffer))) (signal 'wrong-type-argument (list #'bufferp buffer)))
(unless (consp command) (unless (consp command)
(signal 'wrong-type-argument (list #'consp command))) (signal 'wrong-type-argument (list #'consp command)))
(unless (or (null coding) (unless (or (null coding)
@ -4564,7 +4564,7 @@ of."
;; The end. ;; The end.
(when (and (null noninteractive) (when (and (null noninteractive)
(or (eq visit t) (null visit) (stringp visit))) (or (eq visit t) (string-or-null-p visit)))
(tramp-message v 0 "Wrote %s" filename)) (tramp-message v 0 "Wrote %s" filename))
(run-hooks 'tramp-handle-write-region-hook)))) (run-hooks 'tramp-handle-write-region-hook))))
@ -4630,9 +4630,8 @@ of."
(let ((user (or (tramp-file-name-user vec) (let ((user (or (tramp-file-name-user vec)
(with-tramp-connection-property vec "login-as" (with-tramp-connection-property vec "login-as"
(save-window-excursion (save-window-excursion
(let ((enable-recursive-minibuffers t)) (pop-to-buffer (tramp-get-connection-buffer vec))
(pop-to-buffer (tramp-get-connection-buffer vec)) (read-string (match-string 0)))))))
(read-string (match-string 0))))))))
(with-current-buffer (tramp-get-connection-buffer vec) (with-current-buffer (tramp-get-connection-buffer vec)
(tramp-message vec 6 "\n%s" (buffer-string))) (tramp-message vec 6 "\n%s" (buffer-string)))
(tramp-message vec 3 "Sending login name `%s'" user) (tramp-message vec 3 "Sending login name `%s'" user)
@ -4642,8 +4641,7 @@ of."
(defun tramp-action-password (proc vec) (defun tramp-action-password (proc vec)
"Query the user for a password." "Query the user for a password."
(with-current-buffer (process-buffer proc) (with-current-buffer (process-buffer proc)
(let ((enable-recursive-minibuffers t) (let ((case-fold-search t))
(case-fold-search t))
;; Let's check whether a wrong password has been sent already. ;; Let's check whether a wrong password has been sent already.
;; Sometimes, the process returns a new password request ;; Sometimes, the process returns a new password request
;; immediately after rejecting the previous (wrong) one. ;; immediately after rejecting the previous (wrong) one.
@ -4674,14 +4672,13 @@ of."
Send \"yes\" to remote process on confirmation, abort otherwise. Send \"yes\" to remote process on confirmation, abort otherwise.
See also `tramp-action-yn'." See also `tramp-action-yn'."
(save-window-excursion (save-window-excursion
(let ((enable-recursive-minibuffers t)) (pop-to-buffer (tramp-get-connection-buffer vec))
(pop-to-buffer (tramp-get-connection-buffer vec)) (unless (yes-or-no-p (match-string 0))
(unless (yes-or-no-p (match-string 0)) (kill-process proc)
(kill-process proc) (throw 'tramp-action 'permission-denied))
(throw 'tramp-action 'permission-denied)) (with-current-buffer (tramp-get-connection-buffer vec)
(with-current-buffer (tramp-get-connection-buffer vec) (tramp-message vec 6 "\n%s" (buffer-string)))
(tramp-message vec 6 "\n%s" (buffer-string))) (tramp-send-string vec (concat "yes" tramp-local-end-of-line)))
(tramp-send-string vec (concat "yes" tramp-local-end-of-line))))
t) t)
(defun tramp-action-yn (proc vec) (defun tramp-action-yn (proc vec)
@ -4689,14 +4686,13 @@ See also `tramp-action-yn'."
Send \"y\" to remote process on confirmation, abort otherwise. Send \"y\" to remote process on confirmation, abort otherwise.
See also `tramp-action-yesno'." See also `tramp-action-yesno'."
(save-window-excursion (save-window-excursion
(let ((enable-recursive-minibuffers t)) (pop-to-buffer (tramp-get-connection-buffer vec))
(pop-to-buffer (tramp-get-connection-buffer vec)) (unless (y-or-n-p (match-string 0))
(unless (y-or-n-p (match-string 0)) (kill-process proc)
(kill-process proc) (throw 'tramp-action 'permission-denied))
(throw 'tramp-action 'permission-denied)) (with-current-buffer (tramp-get-connection-buffer vec)
(with-current-buffer (tramp-get-connection-buffer vec) (tramp-message vec 6 "\n%s" (buffer-string)))
(tramp-message vec 6 "\n%s" (buffer-string))) (tramp-send-string vec (concat "y" tramp-local-end-of-line)))
(tramp-send-string vec (concat "y" tramp-local-end-of-line))))
t) t)
(defun tramp-action-terminal (_proc vec) (defun tramp-action-terminal (_proc vec)
@ -4830,7 +4826,8 @@ performed successfully. Any other value means an error."
(save-restriction (save-restriction
(with-tramp-progress-reporter (with-tramp-progress-reporter
proc 3 "Waiting for prompts from remote shell" proc 3 "Waiting for prompts from remote shell"
(let (exit) (let ((enable-recursive-minibuffers t)
exit)
(if timeout (if timeout
(with-timeout (timeout (setq exit 'timeout)) (with-timeout (timeout (setq exit 'timeout))
(while (not exit) (while (not exit)