1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Some precisements in Tramp's connection type handling

* doc/misc/tramp.texi (Remote processes): Precise connection type
handling.

* lisp/net/tramp-adb.el (tramp-adb-handle-make-process):
* lisp/net/tramp-sh.el (tramp-sh-handle-make-process):
* lisp/net/tramp.el (tramp-handle-make-process):
Fix :connection-type handling.
(tramp-action-show-and-confirm-message): Pacify byte compiler.

* lisp/net/tramp-compat.el (tramp-compat-ignore-error): New defmacro.

* test/lisp/net/tramp-tests.el (tramp-test29-start-file-process)
(tramp-test30-make-process): Extend tests.
This commit is contained in:
Michael Albinus 2021-08-24 21:42:42 +02:00
parent b8704b52fd
commit efaed29f3d
6 changed files with 103 additions and 50 deletions

View file

@ -925,9 +925,7 @@ implementation will be used."
(coding (plist-get args :coding))
(noquery (plist-get args :noquery))
(connection-type
(if (plist-member args :connection-type)
(plist-get args :connection-type)
tramp-process-connection-type))
(or (plist-get args :connection-type) process-connection-type))
(filter (plist-get args :filter))
(sentinel (plist-get args :sentinel))
(stderr (plist-get args :stderr)))
@ -943,7 +941,9 @@ implementation will be used."
(memq (car coding) coding-system-list)
(memq (cdr coding) coding-system-list)))
(signal 'wrong-type-argument (list #'symbolp coding)))
(unless (memq connection-type '(nil pipe t pty))
(when (eq connection-type t)
(setq connection-type 'pty))
(unless (memq connection-type '(nil pipe pty))
(signal 'wrong-type-argument (list #'symbolp connection-type)))
(unless (or (null filter) (functionp filter))
(signal 'wrong-type-argument (list #'functionp filter)))

View file

@ -295,6 +295,15 @@ A nil value for either argument stands for the current time."
(lambda (reporter &optional value _suffix)
(progress-reporter-update reporter value))))
;; `ignore-error' is new in Emacs Emacs 27.1.
(defmacro tramp-compat-ignore-error (condition &rest body)
"Execute BODY; if the error CONDITION occurs, return nil.
Otherwise, return result of last form in BODY.
CONDITION can also be a list of error conditions."
(declare (debug t) (indent 1))
`(condition-case nil (progn ,@body) (,condition nil)))
;; `file-modes', `set-file-modes' and `set-file-times' got argument
;; FLAG in Emacs 28.1.
(defalias 'tramp-compat-file-modes

View file

@ -2765,9 +2765,7 @@ implementation will be used."
(coding (plist-get args :coding))
(noquery (plist-get args :noquery))
(connection-type
(if (plist-member args :connection-type)
(plist-get args :connection-type)
tramp-process-connection-type))
(or (plist-get args :connection-type) process-connection-type))
(filter (plist-get args :filter))
(sentinel (plist-get args :sentinel))
(stderr (plist-get args :stderr)))
@ -2783,7 +2781,9 @@ implementation will be used."
(memq (car coding) coding-system-list)
(memq (cdr coding) coding-system-list)))
(signal 'wrong-type-argument (list #'symbolp coding)))
(unless (memq connection-type '(nil pipe t pty))
(when (eq connection-type t)
(setq connection-type 'pty))
(unless (memq connection-type '(nil pipe pty))
(signal 'wrong-type-argument (list #'symbolp connection-type)))
(unless (or (null filter) (functionp filter))
(signal 'wrong-type-argument (list #'functionp filter)))

View file

@ -4101,9 +4101,7 @@ substitution. SPEC-LIST is a list of char/value pairs used for
(coding (plist-get args :coding))
(noquery (plist-get args :noquery))
(connection-type
(if (plist-member args :connection-type)
(plist-get args :connection-type)
tramp-process-connection-type))
(or (plist-get args :connection-type) process-connection-type))
(filter (plist-get args :filter))
(sentinel (plist-get args :sentinel))
(stderr (plist-get args :stderr)))
@ -4119,7 +4117,9 @@ substitution. SPEC-LIST is a list of char/value pairs used for
(memq (car coding) coding-system-list)
(memq (cdr coding) coding-system-list)))
(signal 'wrong-type-argument (list #'symbolp coding)))
(unless (memq connection-type '(nil pipe t pty))
(when (eq connection-type t)
(setq connection-type 'pty))
(unless (memq connection-type '(nil pipe pty))
(signal 'wrong-type-argument (list #'symbolp connection-type)))
(unless (or (null filter) (functionp filter))
(signal 'wrong-type-argument (list #'functionp filter)))
@ -4702,13 +4702,15 @@ Wait, until the connection buffer changes."
(let ((stimers (with-timeout-suspend))
(cursor-in-echo-area t)
set-message-function clear-message-function)
;; Silence byte compiler.
(ignore set-message-function clear-message-function)
(tramp-message vec 6 "\n%s" (buffer-string))
(tramp-check-for-regexp proc tramp-process-action-regexp)
(with-temp-message (replace-regexp-in-string "[\r\n]" "" (match-string 0))
;; Hide message in buffer.
(narrow-to-region (point-max) (point-max))
;; Wait for new output.
(while (not (ignore-error 'file-error
(while (not (tramp-compat-ignore-error 'file-error
(tramp-wait-for-regexp
proc 0.1 tramp-security-key-confirmed-regexp)))
(when (tramp-check-for-regexp proc tramp-security-key-timeout-regexp)