* lisp/net/tramp-compat.el (tramp-compat-rx--runtime-params): New defvar.
(tramp-compat-rx--transform-items)
(tramp-compat-rx--transform-item, tramp-compat-rx--transform):
New defuns. Suggested by Mattias EngdegÄrd <mattiase@acm.org>.
(tramp-compat-rx): New defalias or defmacro.
(tramp-compat-string-replace, tramp-compat-string-search):
Use regexp-quote.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-cmds.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Use `tramp-compat-rx' where indicated.
* test/lisp/net/tramp-archive-tests.el:
* test/lisp/net/tramp-tests.el: Use `tramp-compat-rx' where indicated.
"Regexp for date time format in ls output."))
(defconst tramp-adb-ls-date-regexp
- (rx blank (regexp tramp-adb-ls-date-year-regexp)
- blank (regexp tramp-adb-ls-date-time-regexp)
- blank)
+ (tramp-compat-rx
+ blank (regexp tramp-adb-ls-date-year-regexp)
+ blank (regexp tramp-adb-ls-date-time-regexp)
+ blank)
"Regexp for date format in ls output.")
(defconst tramp-adb-ls-toolbox-regexp
- (rx bol (* blank) (group (+ (any ".-" alpha))) ; \1 permissions
- (? (+ blank) (+ digit)) ; links (Android 7/toybox)
- (* blank) (group (+ (not blank))) ; \2 username
- (+ blank) (group (+ (not blank))) ; \3 group
- (+ blank) (group (+ digit)) ; \4 size
- (+ blank) (group (regexp tramp-adb-ls-date-year-regexp)
- blank (regexp tramp-adb-ls-date-time-regexp)) ; \5 date
- blank (group (* nonl)) eol) ; \6 filename
+ (tramp-compat-rx
+ bol (* blank) (group (+ (any ".-" alpha))) ; \1 permissions
+ (? (+ blank) (+ digit)) ; links (Android 7/toybox)
+ (* blank) (group (+ (not blank))) ; \2 username
+ (+ blank) (group (+ (not blank))) ; \3 group
+ (+ blank) (group (+ digit)) ; \4 size
+ (+ blank) (group (regexp tramp-adb-ls-date-year-regexp)
+ blank (regexp tramp-adb-ls-date-time-regexp)) ; \5 date
+ blank (group (* nonl)) eol) ; \6 filename
"Regexp for ls output.")
;;;###tramp-autoload
(tramp-shell-quote-argument
(tramp-compat-file-name-concat localname ".."))))
(tramp-compat-replace-regexp-in-region
- (rx (literal (tramp-compat-file-name-unquote
- (file-name-as-directory localname))))
+ (tramp-compat-rx (literal (tramp-compat-file-name-unquote
+ (file-name-as-directory localname))))
"" (point-min))
(widen)))
(tramp-adb-sh-fix-ls-output)
(goto-char (point-min))
(while
(search-forward-regexp
- (rx blank (group blank (regexp tramp-adb-ls-date-year-regexp) blank))
+ (tramp-compat-rx
+ blank (group blank (regexp tramp-adb-ls-date-year-regexp) blank))
nil t)
(replace-match "0\\1" "\\1" nil)
;; Insert missing "/".
(when (looking-at-p
- (rx (regexp tramp-adb-ls-date-time-regexp) (+ blank) eol))
+ (tramp-compat-rx
+ (regexp tramp-adb-ls-date-time-regexp) (+ blank) eol))
(end-of-line)
(insert "/")))
;; Sort entries.
(i 0)
p)
- (when (string-match-p (rx multibyte) command)
+ (when (string-match-p (tramp-compat-rx multibyte) command)
(tramp-error
v 'file-error "Cannot apply multi-byte command `%s'" command))
(defun tramp-adb-send-command (vec command &optional neveropen nooutput)
"Send the COMMAND to connection VEC."
- (if (string-match-p (rx multibyte) command)
+ (if (string-match-p (tramp-compat-rx multibyte) command)
;; Multibyte codepoints with four bytes are not supported at
;; least by toybox.
;; We can't use stty to disable echo of command. stty is said
;; to be added to toybox 0.7.6. busybox shall have it, but this
;; isn't used any longer for Android.
- (delete-matching-lines (rx bol (literal command) eol))
+ (delete-matching-lines (tramp-compat-rx bol (literal command) eol))
;; When the local machine is W32, there are still trailing ^M.
;; There must be a better solution by setting the correct coding
;; system, but this requires changes in core Tramp.
;; Change prompt.
(tramp-set-connection-property
- p "prompt" (rx "///" (literal prompt) "#$"))
+ p "prompt" (tramp-compat-rx "///" (literal prompt) "#$"))
(tramp-adb-send-command
vec (format "PS1=\"///\"\"%s\"\"#$\"" prompt))
;;;###autoload
(progn (defmacro tramp-archive-autoload-file-name-regexp ()
"Regular expression matching archive file names."
- '(rx bos
- ;; This group is used in `tramp-archive-file-name-archive'.
- (group
- (+ nonl)
- ;; Default suffixes ...
- "." (regexp (regexp-opt tramp-archive-suffixes))
- ;; ... with compression.
- (? "." (regexp (regexp-opt tramp-archive-compression-suffixes))))
- ;; This group is used in `tramp-archive-file-name-localname'.
- (group "/" (* nonl))
- eos)))
+ `(rx
+ bos
+ ;; This group is used in `tramp-archive-file-name-archive'.
+ (group
+ (+ nonl)
+ ;; Default suffixes ...
+ "." ,(cons '| tramp-archive-suffixes)
+ ;; ... with compression.
+ (? "." ,(cons '| tramp-archive-compression-suffixes)))
+ ;; This group is used in `tramp-archive-file-name-localname'.
+ (group "/" (* nonl))
+ eos)))
(put #'tramp-archive-autoload-file-name-regexp 'tramp-autoload t)
(dir (tramp-rename-read-file-name-dir default))
(init (tramp-rename-read-file-name-init default))
(tramp-ignored-file-name-regexp
- (rx (literal (file-remote-p source)))))
+ (tramp-compat-rx (literal (file-remote-p source)))))
(read-file-name-default
"Enter new Tramp connection: "
dir default 'confirm init #'file-directory-p)))))
(dir (tramp-rename-read-file-name-dir default))
(init (tramp-rename-read-file-name-init default))
(tramp-ignored-file-name-regexp
- (rx (literal (file-remote-p source)))))
+ (tramp-compat-rx (literal (file-remote-p source)))))
(read-file-name-default
(format "Change Tramp connection `%s': " source)
dir default 'confirm init #'file-directory-p)))))
(unless (hash-table-p val)
;; Remove string quotation.
(when (looking-at
- (rx bol (group (* anychar)) "\"" ;; \1 "
- (group "(base64-decode-string ") "\\" ;; \2 \
- (group "\"" (* anychar)) "\\" ;; \3 \
- (group "\")") "\"" eol)) ;; \4 "
+ (tramp-compat-rx
+ bol (group (* anychar)) "\"" ;; \1 "
+ (group "(base64-decode-string ") "\\" ;; \2 \
+ (group "\"" (* anychar)) "\\" ;; \3 \
+ (group "\")") "\"" eol)) ;; \4 "
(replace-match "\\1\\2\\3\\4")
(beginning-of-line)
(insert " ;; Variable encoded due to non-printable characters.\n")))
(declare (debug t) (indent 1))
`(condition-case nil (progn ,@body) (,condition nil)))
+;; `rx' in Emacs 26 doesn't know the `literal', `anychar' and
+;; `multibyte' constructs. The `not' construct requires an `any'
+;; construct as argument. The `regexp' construct requires a literal
+;; string.
+(defvar tramp-compat-rx--runtime-params)
+
+(defun tramp-compat-rx--transform-items (items)
+ (mapcar #'tramp-compat-rx--transform-item items))
+
+;; There is an error in Emacs 26. `(rx "a" (? ""))' => "a?".
+;; We must protect the string in regexp and literal, therefore.
+(defun tramp-compat-rx--transform-item (item)
+ (pcase item
+ ('anychar 'anything)
+ ('multibyte 'nonascii)
+ (`(not ,expr)
+ (if (consp expr) item (list 'not (list 'any expr))))
+ (`(regexp ,expr)
+ (setq tramp-compat-rx--runtime-params t)
+ `(regexp ,(list '\, `(concat "\\(?:" ,expr "\\)"))))
+ (`(literal ,expr)
+ (setq tramp-compat-rx--runtime-params t)
+ `(regexp ,(list '\, `(concat "\\(?:" (regexp-quote ,expr) "\\)"))))
+ (`(eval . ,_) item)
+ (`(,head . ,rest) (cons head (tramp-compat-rx--transform-items rest)))
+ (_ item)))
+
+(defun tramp-compat-rx--transform (items)
+ (let* ((tramp-compat-rx--runtime-params nil)
+ (new-rx (cons ': (tramp-compat-rx--transform-items items))))
+ (if tramp-compat-rx--runtime-params
+ `(rx-to-string ,(list '\` new-rx) t)
+ (rx-to-string new-rx t))))
+
+(if (ignore-errors (rx-to-string '(literal "a"))) ;; Emacs 27+.
+ (defalias 'tramp-compat-rx #'rx)
+ (defmacro tramp-compat-rx (&rest items)
+ (tramp-compat-rx--transform items)))
+
+;; This is needed for compilation in the Emacs source tree.
+;;;###autoload (defalias 'tramp-compat-rx #'rx)
+
;; `file-modes', `set-file-modes' and `set-file-times' got argument
;; FLAG in Emacs 28.1.
(defalias 'tramp-compat-file-modes
(lambda (from-string to-string in-string)
(let (case-fold-search)
(replace-regexp-in-string
- (rx (literal from-string)) to-string in-string t t)))))
+ (regexp-quote from-string) to-string in-string t t)))))
;; Function `string-search' is new in Emacs 28.1.
(defalias 'tramp-compat-string-search
#'string-search
(lambda (needle haystack &optional start-pos)
(let (case-fold-search)
- (string-match-p (rx (literal needle)) haystack start-pos)))))
+ (string-match-p (regexp-quote needle) haystack start-pos)))))
;; Function `make-lock-file-name' is new in Emacs 28.1.
(defalias 'tramp-compat-make-lock-file-name
(defun tramp-crypt-handle-access-file (filename string)
"Like `access-file' for Tramp files."
(let* ((encrypt-filename (tramp-crypt-encrypt-file-name filename))
- (encrypt-regexp (rx (literal encrypt-filename) eos))
+ (encrypt-regexp (tramp-compat-rx (literal encrypt-filename) eos))
tramp-crypt-enabled)
(condition-case err
(access-file encrypt-filename string)
(mapcar
(lambda (x)
(replace-regexp-in-string
- (rx bos (literal directory)) ""
+ (tramp-compat-rx bos (literal directory)) ""
(tramp-crypt-decrypt-file-name x)))
(directory-files (tramp-crypt-encrypt-file-name directory) 'full)))))
(tramp-fuse-local-file-name directory))))))))
(if full
;; Massage the result.
- (let ((local (rx bol
- (literal
- (tramp-fuse-mount-point
- (tramp-dissect-file-name directory)))))
+ (let ((local (tramp-compat-rx
+ bol
+ (literal
+ (tramp-fuse-mount-point
+ (tramp-dissect-file-name directory)))))
(remote (directory-file-name
(funcall
(if (tramp-compat-file-name-quoted-p directory)
(tramp-set-file-property
vec "/" "mounted"
(when (string-match
- (rx bol (group (literal (tramp-fuse-mount-spec vec))) blank)
+ (tramp-compat-rx
+ bol (group (literal (tramp-fuse-mount-spec vec))) blank)
mount)
(match-string 1 mount)))))))
;; </interface>
(defconst tramp-goa-identity-regexp
- (rx bol (? (group (regexp tramp-user-regexp)))
- "@" (? (group (regexp tramp-host-regexp)))
- (? ":" (group (regexp tramp-port-regexp))))
+ (tramp-compat-rx
+ bol (? (group (regexp tramp-user-regexp)))
+ "@" (? (group (regexp tramp-host-regexp)))
+ (? ":" (group (regexp tramp-port-regexp))))
"Regexp matching GNOME Online Accounts \"PresentationIdentity\" property.")
(defconst tramp-goa-interface-mail "org.gnome.OnlineAccounts.Mail"
"GVFS file attributes."))
(defconst tramp-gvfs-file-attributes-with-gvfs-ls-regexp
- (rx blank (group (regexp (regexp-opt tramp-gvfs-file-attributes)))
- "=" (group (+? nonl)))
+ (tramp-compat-rx
+ blank (group (regexp (regexp-opt tramp-gvfs-file-attributes)))
+ "=" (group (+? nonl)))
"Regexp to parse GVFS file attributes with `gvfs-ls'.")
(defconst tramp-gvfs-file-attributes-with-gvfs-info-regexp
- (rx bol (* blank) (group (regexp (regexp-opt tramp-gvfs-file-attributes)))
- ":" (+ blank) (group (* nonl)) eol)
+ (tramp-compat-rx
+ bol (* blank) (group (regexp (regexp-opt tramp-gvfs-file-attributes)))
+ ":" (+ blank) (group (* nonl)) eol)
"Regexp to parse GVFS file attributes with `gvfs-info'.")
(defconst tramp-gvfs-file-system-attributes
"GVFS file system attributes.")
(defconst tramp-gvfs-file-system-attributes-regexp
- (rx bol (* blank)
- (group (regexp (regexp-opt tramp-gvfs-file-system-attributes)))
- ":" (+ blank) (group (* nonl)) eol)
+ (tramp-compat-rx
+ bol (* blank)
+ (group (regexp (regexp-opt tramp-gvfs-file-system-attributes)))
+ ":" (+ blank) (group (* nonl)) eol)
"Regexp to parse GVFS file system attributes with `gvfs-info'.")
(defconst tramp-gvfs-nextcloud-default-prefix "/remote.php/webdav"
"Default prefix for owncloud / nextcloud methods.")
(defconst tramp-gvfs-nextcloud-default-prefix-regexp
- (rx (literal tramp-gvfs-nextcloud-default-prefix) eol)
+ (tramp-compat-rx (literal tramp-gvfs-nextcloud-default-prefix) eol)
"Regexp of default prefix for owncloud / nextcloud methods.")
\f
(with-parsed-tramp-file-name name nil
;; If there is a default location, expand tilde.
(when (string-match
- (rx bos "~" (group (* (not (any "/")))) (group (* nonl)) eos)
+ (tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
;; We do not pass "/..".
(if (string-match-p (rx bos (| "afp" (: "dav" (? "s")) "smb") eos) method)
(when (string-match
- (rx bos "/" (+ (not (any "/"))) (group "/.." (? "/")))
+ (tramp-compat-rx bos "/" (+ (not "/")) (group "/.." (? "/")))
localname)
(setq localname (replace-match "/" t t localname 1)))
(when (string-match (rx bol "/.." (? "/")) localname)
(with-current-buffer (tramp-get-connection-buffer v)
(goto-char (point-min))
(while (looking-at
- (rx bol (group (+ nonl)) blank
- (group (+ digit)) blank
- "(" (group (+? nonl)) ")"
- (regexp tramp-gvfs-file-attributes-with-gvfs-ls-regexp)))
+ (tramp-compat-rx
+ bol (group (+ nonl)) blank
+ (group (+ digit)) blank
+ "(" (group (+? nonl)) ")"
+ (regexp tramp-gvfs-file-attributes-with-gvfs-ls-regexp)))
(let ((item (list (cons "type" (match-string 3))
(cons "standard::size" (match-string 2))
(cons "name" (match-string 1)))))
(goto-char (1+ (match-end 3)))
(while (looking-at
- (rx (regexp tramp-gvfs-file-attributes-with-gvfs-ls-regexp)
- (group
- (| (regexp
- tramp-gvfs-file-attributes-with-gvfs-ls-regexp)
- eol))))
+ (tramp-compat-rx
+ (regexp tramp-gvfs-file-attributes-with-gvfs-ls-regexp)
+ (group
+ (| (regexp
+ tramp-gvfs-file-attributes-with-gvfs-ls-regexp)
+ eol))))
(push (cons (match-string 1) (match-string 2)) item)
(goto-char (match-end 2)))
;; Add display name as head.
(if (or (and (string-match-p
(rx bol (| "afp" (: "dav" (? "s")) "smb") eol) method)
(string-match-p
- (rx bol (? "/") (+ (not (any "/"))) eol) localname))
+ (tramp-compat-rx bol (? "/") (+ (not "/")) eol) localname))
(string-equal localname "/"))
(tramp-gvfs-get-root-attributes filename)
(assoc
(let* ((events (process-get proc 'events))
(rest-string (process-get proc 'rest-string))
(dd (tramp-get-default-directory (process-buffer proc)))
- (ddu (rx (literal (tramp-gvfs-url-file-name dd)))))
+ (ddu (tramp-compat-rx (literal (tramp-gvfs-url-file-name dd)))))
(when rest-string
(tramp-message proc 10 "Previous string:\n%s" rest-string))
(tramp-message proc 6 "%S\n%s" proc string)
(delete-process proc))
(while (string-match
- (rx bol (+ nonl) ":"
- blank (group (+ nonl)) ":"
- blank (group (regexp (regexp-opt tramp-gio-events)))
- (? (group blank (group (+ nonl)))) eol)
+ (tramp-compat-rx
+ bol (+ nonl) ":"
+ blank (group (+ nonl)) ":"
+ blank (group (regexp (regexp-opt tramp-gio-events)))
+ (? (group blank (group (+ nonl)))) eol)
string)
(let ((file (match-string 1 string))
"Retrieve file name from D-Bus OBJECT-PATH."
(dbus-unescape-from-identifier
(replace-regexp-in-string
- (rx bol (* nonl) "/" (group (+ (not (any "/")))) eol) "\\1" object-path)))
+ (tramp-compat-rx bol (* nonl) "/" (group (+ (not "/"))) eol) "\\1"
+ object-path)))
(defun tramp-gvfs-url-host (url)
"Return the host name part of URL, a string.
(string-equal domain (tramp-file-name-domain vec))
(string-equal host (tramp-file-name-host vec))
(string-equal port (tramp-file-name-port vec))
- (string-match-p (rx bol "/" (literal (or share "")))
- (tramp-file-name-unquote-localname vec)))
+ (string-match-p
+ (tramp-compat-rx bol "/" (literal (or share "")))
+ (tramp-file-name-unquote-localname vec)))
;; Set mountpoint and location.
(tramp-set-file-property vec "/" "fuse-mountpoint" fuse-mountpoint)
(tramp-set-connection-property
(tramp-media-device-port media) (tramp-file-name-port vec)))
(localname (tramp-file-name-unquote-localname vec))
(share (when (string-match
- (rx bol (? "/") (group (+ (not (any "/"))))) localname)
+ (tramp-compat-rx bol (? "/") (group (+ (not "/"))))
+ localname)
(match-string 1 localname)))
(ssl (if (string-match-p (rx bol (| "davs" "nextcloud")) method)
"true" "false"))
(list (tramp-gvfs-mount-spec-entry "port" port)))))
(mount-pref
(if (and (string-match-p (rx bol "dav") method)
- (string-match (rx bol (? "/") (+ (not (any "/")))) localname))
+ (string-match
+ (tramp-compat-rx bol (? "/") (+ (not "/"))) localname))
(match-string 0 localname)
(tramp-gvfs-get-remote-prefix vec))))
(add-to-list 'tramp-default-method-alist
`(,tramp-local-host-regexp
- ,(rx bos (literal tramp-root-id-string) eos) "su"))
+ ,(tramp-compat-rx bos (literal tramp-root-id-string) eos) "su"))
(add-to-list 'tramp-default-user-alist
`(,(rx bos (| "su" "sudo" "doas" "ksu") eos)
(with-parsed-tramp-file-name filename nil
(with-tramp-file-property v localname "file-selinux-context"
(let ((context '(nil nil nil nil))
- (regexp (rx (group (+ (any "_" alnum))) ":"
- (group (+ (any "_" alnum))) ":"
- (group (+ (any "_" alnum))) ":"
- (group (+ (any "_" alnum))))))
+ (regexp (tramp-compat-rx
+ (group (+ (any "_" alnum))) ":"
+ (group (+ (any "_" alnum))) ":"
+ (group (+ (any "_" alnum))) ":"
+ (group (+ (any "_" alnum))))))
(when (and (tramp-remote-selinux-p v)
(tramp-send-command-and-check
v (format
;; by `file-name-absolute-p'.
(if (and (eq system-type 'windows-nt)
(string-match-p
- (rx bol (| (: alpha ":") (: (literal null-device) eol))) name))
+ (tramp-compat-rx bol (| (: alpha ":") (: (literal null-device) eol)))
+ name))
(tramp-run-real-handler #'expand-file-name (list name dir))
;; Unless NAME is absolute, concat DIR and NAME.
(unless (file-name-absolute-p name)
;; supposed to find such a shell on the remote host. Please
;; tell me about it when this doesn't work on your system.
(when (string-match
- (rx bos "~" (group (* (not (any "/")))) (group (* nonl)) eos)
+ (tramp-compat-rx
+ bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
(setq string (tramp-compat-string-replace "\n\n" "\n" string))
(while (string-match
- (rx bol (+ (not (any ":"))) ":" blank
- (group (+ (not (any ":")))) ":" blank
- (group (regexp (regexp-opt tramp-gio-events)))
- (? blank (group (+ (not (any ":"))))) eol)
+ (tramp-compat-rx
+ bol (+ (not ":")) ":" blank
+ (group (+ (not ":"))) ":" blank
+ (group (regexp (regexp-opt tramp-gio-events)))
+ (? blank (group (+ (not ":")))) eol)
string)
(let* ((file (match-string 1 string))
local commands are used. If there is a format specifier which
cannot be expanded, this function returns nil."
(if (not (string-match-p
- (rx (| bol (not (any "%"))) "%" (any "ahlnoprsty")) script))
+ (tramp-compat-rx (| bol (not "%")) "%" (any "ahlnoprsty")) script))
script
(catch 'wont-work
- (let ((awk (when (string-match-p (rx (| bol (not (any "%"))) "%a") script)
+ (let ((awk (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%a") script)
(or
(if vec (tramp-get-remote-awk vec) (executable-find "awk"))
(throw 'wont-work nil))))
- (hdmp (when (string-match-p (rx (| bol (not (any "%"))) "%h") script)
+ (hdmp (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%h") script)
(or
(if vec (tramp-get-remote-hexdump vec)
(executable-find "hexdump"))
(throw 'wont-work nil))))
- (dev (when (string-match-p (rx (| bol (not (any "%"))) "%n") script)
+ (dev (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%n") script)
(or
(if vec (concat "2>" (tramp-get-remote-null-device vec))
(if (eq system-type 'windows-nt) ""
(concat "2>" null-device)))
(throw 'wont-work nil))))
- (ls (when (string-match-p (rx (| bol (not (any "%"))) "%l") script)
+ (ls (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%l") script)
(format "%s %s"
(or (tramp-get-ls-command vec)
(throw 'wont-work nil))
(tramp-sh--quoting-style-options vec))))
- (od (when (string-match-p (rx (| bol (not (any "%"))) "%o") script)
+ (od (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%o") script)
(or (if vec (tramp-get-remote-od vec) (executable-find "od"))
(throw 'wont-work nil))))
- (perl (when (string-match-p (rx (| bol (not (any "%"))) "%p") script)
+ (perl (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%p") script)
(or
(if vec
(tramp-get-remote-perl vec) (executable-find "perl"))
(throw 'wont-work nil))))
- (python (when (string-match-p (rx (| bol (not (any "%"))) "%y") script)
+ (python (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%y") script)
(or
(if vec
- (tramp-get-remote-python vec) (executable-find "python"))
+ (tramp-get-remote-python vec)
+ (executable-find "python"))
(throw 'wont-work nil))))
(readlink (when (string-match-p
- (rx (| bol (not (any "%"))) "%r") script)
+ (tramp-compat-rx (| bol (not "%")) "%r") script)
(or
(if vec
(tramp-get-remote-readlink vec)
(executable-find "readlink"))
(throw 'wont-work nil))))
- (stat (when (string-match-p (rx (| bol (not (any "%"))) "%s") script)
+ (stat (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%s") script)
(or
(if vec
(tramp-get-remote-stat vec) (executable-find "stat"))
(throw 'wont-work nil))))
- (tmp (when (string-match-p (rx (| bol (not (any "%"))) "%t") script)
+ (tmp (when (string-match-p
+ (tramp-compat-rx (| bol (not "%")) "%t") script)
(or
(if vec
(tramp-file-local-name (tramp-make-tramp-temp-name vec))
"Couldn't find remote shell prompt for %s" shell)
(unless
(tramp-check-for-regexp
- (tramp-get-connection-process vec) (rx (literal tramp-end-of-output)))
+ (tramp-get-connection-process vec)
+ (tramp-compat-rx (literal tramp-end-of-output)))
(tramp-wait-for-output (tramp-get-connection-process vec))
(tramp-message vec 5 "Setting shell prompt")
(tramp-send-command
(tramp-send-command
vec (format "echo ~%s" tramp-root-id-string) t)
(if (or (string-match-p
- (rx bol "~" (literal tramp-root-id-string) eol)
+ (tramp-compat-rx
+ bol "~" (literal tramp-root-id-string) eol)
(buffer-string))
;; The default shell (ksh93) of OpenSolaris
;; and Solaris is buggy. We've got reports
(condition-case nil
(tramp-wait-for-regexp
proc timeout
- (rx (| (regexp shell-prompt-pattern)
- (regexp tramp-shell-prompt-pattern))
- eos))
+ (tramp-compat-rx
+ (| (regexp shell-prompt-pattern) (regexp tramp-shell-prompt-pattern))
+ eos))
(error
(delete-process proc)
(apply #'tramp-error-with-buffer
(with-current-buffer (tramp-get-connection-buffer vec)
(goto-char (point-min))
- (unless (looking-at-p (rx (literal magic)))
+ (unless (looking-at-p (tramp-compat-rx (literal magic)))
(throw 'wont-work-remote nil)))
;; `rem-enc' and `rem-dec' could be a string meanwhile.
nil t))
(throw 'next nil))
(goto-char (point-min))
- (unless (looking-at-p (rx (literal magic)))
+ (unless (looking-at-p (tramp-compat-rx (literal magic)))
(throw 'next nil)))
(tramp-message
vec 5
(throw 'next nil))
(with-current-buffer (tramp-get-buffer vec)
(goto-char (point-min))
- (unless (looking-at-p (rx (literal magic)))
+ (unless (looking-at-p (tramp-compat-rx (literal magic)))
(throw 'next nil)))
(setq found t)))
;; Busyboxes built with the EDITING_ASK_TERMINAL config
;; option send also escape sequences, which must be
;; ignored.
- (regexp (rx (* (not (any "#$\n")))
- (literal tramp-end-of-output)
- (? (regexp tramp-device-escape-sequence-regexp))
- (? "\r") eol))
+ (regexp (tramp-compat-rx
+ (* (not (any "#$\n")))
+ (literal tramp-end-of-output)
+ (? (regexp tramp-device-escape-sequence-regexp))
+ (? "\r") eol))
;; Sometimes, the commands do not return a newline but a
;; null byte before the shell prompt, for example "git
;; ls-files -c -z ...".
- (regexp1 (rx (| bol "\000") (regexp regexp)))
+ (regexp1 (tramp-compat-rx (| bol "\000") (regexp regexp)))
(found (tramp-wait-for-regexp proc timeout regexp1)))
(if found
(let ((inhibit-read-only t))
(let (cmd data)
(if (and (stringp command)
(string-match
- (rx (* nonl) "<<'" (literal tramp-end-of-heredoc) "'" (* nonl))
+ (tramp-compat-rx
+ (* nonl) "<<'" (literal tramp-end-of-heredoc) "'" (* nonl))
command))
(setq cmd (match-string 0 command)
data (substring command (match-end 0)))
(tramp-get-method-parameter vec 'tramp-remote-shell-args)
" ")
(tramp-shell-quote-argument tramp-end-of-heredoc))
- 'noerror (rx (literal tramp-end-of-heredoc)))
+ 'noerror (tramp-compat-rx (literal tramp-end-of-heredoc)))
(progn
(tramp-message
vec 2 "Could not retrieve `tramp-own-remote-path'")
(while candidates
(goto-char (point-min))
(if (string-match-p
- (rx bol (literal (car candidates)) (? "\r") eol)
+ (tramp-compat-rx bol (literal (car candidates)) (? "\r") eol)
(buffer-string))
(setq locale (car candidates)
candidates nil)
vec (format "( %s / -nt / )" (tramp-get-test-command vec)))
(with-current-buffer (tramp-get-buffer vec)
(goto-char (point-min))
- (when (looking-at-p (rx (literal tramp-end-of-output)))
+ (when (looking-at-p (tramp-compat-rx (literal tramp-end-of-output)))
(format "%s %%s -nt %%s" (tramp-get-test-command vec)))))
(progn
(tramp-send-command
;;;###tramp-autoload
(tramp--with-startup
(add-to-list 'tramp-default-user-alist
- `(,(rx bos (literal tramp-smb-method) eos) nil nil))
+ `(,(tramp-compat-rx bos (literal tramp-smb-method) eos) nil nil))
;; Add completion function for SMB method.
(tramp-set-completion-function
"Version string of the SMB client.")
(defconst tramp-smb-server-version
- (rx "Domain=[" (* (not (any "]"))) "] "
- "OS=[" (* (not (any "]"))) "] "
- "Server=[" (* (not (any "]"))) "]")
+ (tramp-compat-rx "Domain=[" (* (not "]")) "] "
+ "OS=[" (* (not "]")) "] "
+ "Server=[" (* (not "]")) "]")
"Regexp of SMB server identification.")
(defconst tramp-smb-prompt
(with-parsed-tramp-file-name name nil
;; Tilde expansion if necessary.
(when (string-match
- (rx bos "~" (group (* (not (any "/")))) (group (* nonl)) eos)
+ (tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
;; Check for matching entries.
(mapcar
(lambda (x)
- (when (string-match-p (rx bol (literal base)) (nth 0 x))
+ (when (string-match-p
+ (tramp-compat-rx bol (literal base)) (nth 0 x))
x))
entries)
;; We just need the only and only entry FILENAME.
(save-match-data
(let ((localname (tramp-file-name-unquote-localname vec)))
(when (string-match
- (rx bol (? "/") (group (+ (not (any "/")))) "/") localname)
+ (tramp-compat-rx bol (? "/") (group (+ (not "/"))) "/") localname)
(match-string 1 localname)))))
(defun tramp-smb-get-localname (vec)
(setq
localname
(if (string-match
- (rx bol (? "/") (+ (not (any "/"))) (group "/" (* nonl))) localname)
+ (tramp-compat-rx bol (? "/") (+ (not "/")) (group "/" (* nonl)))
+ localname)
;; There is a share, separated by "/".
(if (not (tramp-smb-get-cifs-capabilities vec))
(mapconcat
(match-string 1 localname))
;; There is just a share.
(if (string-match
- (rx bol (? "/") (group (+ (not (any "/")))) eol) localname)
+ (tramp-compat-rx bol (? "/") (group (+ (not "/"))) eol) localname)
(match-string 1 localname)
"")))
;; Read share entries.
(when (string-match
- (rx bol "Disk|" (group (+ (not (any "|")))) "|") line)
+ (tramp-compat-rx bol "Disk|" (group (+ (not "|"))) "|") line)
(setq localname (match-string 1 line)
mode "dr-xr-xr-x"
size 0))
(tramp-password-previous-hop t)))
(add-to-list 'tramp-default-user-alist
- `(,(rx bos (literal tramp-sudoedit-method) eos)
+ `(,(tramp-compat-rx bos (literal tramp-sudoedit-method) eos)
nil ,tramp-root-id-string))
(tramp-set-completion-function
(unless (file-name-absolute-p localname)
(setq localname (format "~%s/%s" user localname)))
(when (string-match
- (rx bos "~" (group (* (not (any "/")))) (group (* nonl)) eos)
+ (tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
(with-parsed-tramp-file-name filename nil
(with-tramp-file-property v localname "file-selinux-context"
(let ((context '(nil nil nil nil))
- (regexp (rx (group (+ (any "_" alnum))) ":"
- (group (+ (any "_" alnum))) ":"
- (group (+ (any "_" alnum))) ":"
- (group (+ (any "_" alnum))))))
+ (regexp (tramp-compat-rx
+ (group (+ (any "_" alnum))) ":"
+ (group (+ (any "_" alnum))) ":"
+ (group (+ (any "_" alnum))) ":"
+ (group (+ (any "_" alnum))))))
(when (and (tramp-sudoedit-remote-selinux-p v)
(tramp-sudoedit-send-command
v "ls" "-d" "-Z"
(defcustom tramp-restricted-shell-hosts-alist
(when (and (eq system-type 'windows-nt)
(not (string-match-p (rx "sh" eol) tramp-encoding-shell)))
- (list (rx bos (| (literal (downcase tramp-system-name))
- (literal (upcase tramp-system-name)))
- eos)))
+ (list (tramp-compat-rx
+ bos (| (literal (downcase tramp-system-name))
+ (literal (upcase tramp-system-name)))
+ eos)))
"List of hosts, which run a restricted shell.
This is a list of regular expressions, which denote hosts running
a restricted shell like \"rbash\". Those hosts can be used as
;;;###tramp-autoload
(defcustom tramp-local-host-regexp
- (rx bos
- (| (literal tramp-system-name)
- (| "localhost" "localhost4" "localhost6" "127.0.0.1" "::1"))
- eos)
+ (tramp-compat-rx
+ bos
+ (| (literal tramp-system-name)
+ (| "localhost" "localhost4" "localhost6" "127.0.0.1" "::1"))
+ eos)
"Host names which are regarded as local host.
If the local host runs a chrooted environment, set this to nil."
:version "29.1"
:type 'regexp)
(defcustom tramp-password-prompt-regexp
- (rx bol (* nonl)
- (group (regexp (regexp-opt password-word-equivalents)))
- (* nonl) ":" (? "\^@") (* blank))
+ (tramp-compat-rx
+ bol (* nonl)
+ (group (regexp (regexp-opt password-word-equivalents)))
+ (* nonl) ":" (? "\^@") (* blank))
"Regexp matching password-like prompts.
The regexp should match at end of buffer.
(defun tramp-build-prefix-regexp ()
"Return `tramp-prefix-regexp'."
- (rx bol (literal (tramp-build-prefix-format))))
+ (tramp-compat-rx bol (literal (tramp-build-prefix-format))))
(defvar tramp-prefix-regexp nil ; Initialized when defining `tramp-syntax'!
"Regexp matching the very beginning of Tramp file names.
Should always start with \"^\". Derived from `tramp-prefix-format'.")
(defconst tramp-method-regexp-alist
- `((default . ,(rx (| (literal tramp-default-method-marker) (>= 2 alnum))))
+ `((default . ,(tramp-compat-rx
+ (| (literal tramp-default-method-marker) (>= 2 alnum))))
(simplified . "")
- (separate
- . ,(rx (? (| (literal tramp-default-method-marker) (>= 2 alnum))))))
+ (separate . ,(tramp-compat-rx
+ (? (| (literal tramp-default-method-marker) (>= 2 alnum))))))
"Alist mapping Tramp syntax to regexps matching methods identifiers.")
(defun tramp-build-method-regexp ()
(defun tramp-build-postfix-method-regexp ()
"Return `tramp-postfix-method-regexp'."
- (rx (literal (tramp-build-postfix-method-format))))
+ (tramp-compat-rx (literal (tramp-build-postfix-method-format))))
(defvar tramp-postfix-method-regexp nil ; Init'd when defining `tramp-syntax'!
"Regexp matching delimiter between method and user or host names.
(defconst tramp-prefix-domain-format "%"
"String matching delimiter between user and domain names.")
-(defconst tramp-prefix-domain-regexp (rx (literal tramp-prefix-domain-format))
+(defconst tramp-prefix-domain-regexp
+ (tramp-compat-rx (literal tramp-prefix-domain-format))
"Regexp matching delimiter between user and domain names.
Derived from `tramp-prefix-domain-format'.")
"Regexp matching domain names.")
(defconst tramp-user-with-domain-regexp
- (rx (group (regexp tramp-user-regexp))
- (regexp tramp-prefix-domain-regexp)
- (group (regexp tramp-domain-regexp)))
+ (tramp-compat-rx
+ (group (regexp tramp-user-regexp))
+ (regexp tramp-prefix-domain-regexp)
+ (group (regexp tramp-domain-regexp)))
"Regexp matching user names with domain names.")
(defconst tramp-postfix-user-format "@"
"String matching delimiter between user and host names.
Used in `tramp-make-tramp-file-name'.")
-(defconst tramp-postfix-user-regexp (rx (literal tramp-postfix-user-format))
+(defconst tramp-postfix-user-regexp
+ (tramp-compat-rx (literal tramp-postfix-user-format))
"Regexp matching delimiter between user and host names.
Derived from `tramp-postfix-user-format'.")
(defun tramp-build-prefix-ipv6-regexp ()
"Return `tramp-prefix-ipv6-regexp'."
- (rx (literal tramp-prefix-ipv6-format)))
+ (tramp-compat-rx (literal tramp-prefix-ipv6-format)))
(defvar tramp-prefix-ipv6-regexp nil ; Initialized when defining `tramp-syntax'!
"Regexp matching left hand side of IPv6 addresses.
(defun tramp-build-postfix-ipv6-regexp ()
"Return `tramp-postfix-ipv6-regexp'."
- (rx (literal tramp-postfix-ipv6-format)))
+ (tramp-compat-rx (literal tramp-postfix-ipv6-format)))
(defvar tramp-postfix-ipv6-regexp nil ; Initialized when defining `tramp-syntax'!
"Regexp matching right hand side of IPv6 addresses.
(defconst tramp-prefix-port-format "#"
"String matching delimiter between host names and port numbers.")
-(defconst tramp-prefix-port-regexp (rx (literal tramp-prefix-port-format))
+(defconst tramp-prefix-port-regexp
+ (tramp-compat-rx (literal tramp-prefix-port-format))
"Regexp matching delimiter between host names and port numbers.
Derived from `tramp-prefix-port-format'.")
"Regexp matching port numbers.")
(defconst tramp-host-with-port-regexp
- (rx (group (regexp tramp-host-regexp))
- (regexp tramp-prefix-port-regexp)
- (group (regexp tramp-port-regexp)))
+ (tramp-compat-rx
+ (group (regexp tramp-host-regexp))
+ (regexp tramp-prefix-port-regexp)
+ (group (regexp tramp-port-regexp)))
"Regexp matching host names with port numbers.")
(defconst tramp-postfix-hop-format "|"
"String matching delimiter after ad-hoc hop definitions.")
-(defconst tramp-postfix-hop-regexp (rx (literal tramp-postfix-hop-format))
+(defconst tramp-postfix-hop-regexp
+ (tramp-compat-rx (literal tramp-postfix-hop-format))
"Regexp matching delimiter after ad-hoc hop definitions.
Derived from `tramp-postfix-hop-format'.")
(defun tramp-build-postfix-host-regexp ()
"Return `tramp-postfix-host-regexp'."
- (rx (literal tramp-postfix-host-format)))
+ (tramp-compat-rx (literal tramp-postfix-host-format)))
(defvar tramp-postfix-host-regexp nil ; Initialized when defining `tramp-syntax'!
"Regexp matching delimiter between host names and localnames.
(defun tramp-build-remote-file-name-spec-regexp ()
"Construct a regexp matching a Tramp file name for a Tramp syntax.
It is expected, that `tramp-syntax' has the proper value."
- (rx ;; Method.
- (group (regexp tramp-method-regexp)) (regexp tramp-postfix-method-regexp)
- ;; Optional user.
- (? (group (regexp tramp-user-regexp)) (regexp tramp-postfix-user-regexp))
- ;; Optional host.
- (? (group (| (regexp tramp-host-regexp)
- (: (regexp tramp-prefix-ipv6-regexp)
- (? (regexp tramp-ipv6-regexp))
- (regexp tramp-postfix-ipv6-regexp)))
- ;; Optional port.
- (? (regexp tramp-prefix-port-regexp) (regexp tramp-port-regexp))))))
+ (tramp-compat-rx
+ ;; Method.
+ (group (regexp tramp-method-regexp)) (regexp tramp-postfix-method-regexp)
+ ;; Optional user. This includes domain.
+ (? (group (regexp tramp-user-regexp)) (regexp tramp-postfix-user-regexp))
+ ;; Optional host.
+ (? (group (| (regexp tramp-host-regexp)
+ (: (regexp tramp-prefix-ipv6-regexp)
+ (? (regexp tramp-ipv6-regexp))
+ (regexp tramp-postfix-ipv6-regexp)))
+ ;; Optional port.
+ (? (regexp tramp-prefix-port-regexp) (regexp tramp-port-regexp))))))
(defvar tramp-remote-file-name-spec-regexp
nil ; Initialized when defining `tramp-syntax'!
It is expected, that `tramp-syntax' has the proper value.
See `tramp-file-name-structure'."
(list
- (rx (regexp tramp-prefix-regexp)
- (? (group (+ (regexp tramp-remote-file-name-spec-regexp)
- (regexp tramp-postfix-hop-regexp))))
- (regexp tramp-remote-file-name-spec-regexp)
- (regexp tramp-postfix-host-regexp)
- (group (regexp tramp-localname-regexp)))
+ (tramp-compat-rx
+ (regexp tramp-prefix-regexp)
+ (? (group (+ (regexp tramp-remote-file-name-spec-regexp)
+ (regexp tramp-postfix-hop-regexp))))
+ (regexp tramp-remote-file-name-spec-regexp)
+ (regexp tramp-postfix-host-regexp)
+ (group (regexp tramp-localname-regexp)))
5 6 7 8 1))
(defvar tramp-file-name-structure nil ; Initialized when defining `tramp-syntax'!
;; `tramp-method-regexp' needs at least two characters, in order to
;; distinguish from volume letter. This is in the way when completing.
(defconst tramp-completion-method-regexp-alist
- `((default . ,(rx (| (literal tramp-default-method-marker) (+ alnum))))
+ `((default . ,(tramp-compat-rx
+ (| (literal tramp-default-method-marker) (+ alnum))))
(simplified . "")
- (separate . ,(rx (| (literal tramp-default-method-marker) (* alnum)))))
+ (separate . ,(tramp-compat-rx
+ (| (literal tramp-default-method-marker) (* alnum)))))
"Alist mapping Tramp syntax to regexps matching completion methods.")
(defun tramp-build-completion-method-regexp ()
"Return `tramp-completion-file-name-regexp' according to `tramp-syntax'."
(if (eq tramp-syntax 'separate)
;; FIXME: This shouldn't be necessary.
- (rx bos "/" (? "[" (* (not (any "]")))) eos)
- (rx bos
- ;; `file-name-completion' uses absolute paths for matching.
- ;; This means that on W32 systems, something like
- ;; "/ssh:host:~/path" becomes "c:/ssh:host:~/path". See also
- ;; `tramp-drop-volume-letter'.
- (? (regexp tramp-volume-letter-regexp))
- (regexp tramp-prefix-regexp)
-
- ;; Optional multi hops.
- (* (regexp tramp-remote-file-name-spec-regexp)
- (regexp tramp-postfix-hop-regexp))
-
- ;; Last hop.
- (? (regexp tramp-completion-method-regexp)
- ;; Method separator, user name and host name.
- (? (regexp tramp-postfix-method-regexp)
- ;; This is a little bit lax, but it serves.
- (? (regexp tramp-host-regexp))))
-
- eos)))
+ (tramp-compat-rx bos "/" (? "[" (* (not "]"))) eos)
+ (tramp-compat-rx
+ bos
+ ;; `file-name-completion' uses absolute paths for matching.
+ ;; This means that on W32 systems, something like
+ ;; "/ssh:host:~/path" becomes "c:/ssh:host:~/path". See also
+ ;; `tramp-drop-volume-letter'.
+ (? (regexp tramp-volume-letter-regexp))
+ (regexp tramp-prefix-regexp)
+
+ ;; Optional multi hops.
+ (* (regexp tramp-remote-file-name-spec-regexp)
+ (regexp tramp-postfix-hop-regexp))
+
+ ;; Last hop.
+ (? (regexp tramp-completion-method-regexp)
+ ;; Method separator, user name and host name.
+ (? (regexp tramp-postfix-method-regexp)
+ ;; This is a little bit lax, but it serves.
+ (? (regexp tramp-host-regexp))))
+
+ eos)))
(defvar tramp-completion-file-name-regexp
nil ; Initialized when defining `tramp-syntax'!
(let ((v (tramp-dissect-file-name
(concat tramp-prefix-format
(replace-regexp-in-string
- (rx (regexp tramp-postfix-hop-regexp) eos)
+ (tramp-compat-rx (regexp tramp-postfix-hop-regexp) eos)
tramp-postfix-host-format name))
nodefault)))
;; Only some methods from tramp-sh.el do support multi-hops.
(replace-regexp-in-string
tramp-prefix-regexp ""
(replace-regexp-in-string
- (rx (regexp tramp-postfix-host-regexp) eos) tramp-postfix-hop-format
+ (tramp-compat-rx
+ (regexp tramp-postfix-host-regexp) eos) tramp-postfix-hop-format
(tramp-make-tramp-file-name vec 'noloc)))))
(defun tramp-completion-make-tramp-file-name (method user host localname)
;; Also, in `font-lock-defaults' you can specify a function name for
;; the "KEYWORDS" part, so font-lock calls it to get the actual keywords!
'(list
- (rx bol (regexp tramp-debug-outline-regexp) (+ nonl))
+ (tramp-compat-rx bol (regexp tramp-debug-outline-regexp) (+ nonl))
'(1 font-lock-warning-face t t)
'(0 (outline-font-lock-face) keep t))
"Used for highlighting Tramp debug buffers in `outline-mode'.")
(let ((quoted (tramp-compat-file-name-quoted-p name 'top))
(result (tramp-compat-file-name-unquote name 'top)))
(setq result
- (if (string-match
- (rx (regexp tramp-volume-letter-regexp) "/") result)
- (replace-match "/" nil t result) result))
+ (replace-regexp-in-string
+ (tramp-compat-rx (regexp tramp-volume-letter-regexp) "/")
+ "/" result))
(if quoted (tramp-compat-file-name-quote result 'top) result))))
;;; Config Manipulation Functions:
;; We found a matching entry in `file-coding-system-alist'.
;; So we add a similar entry, but with the temporary file name
;; as regexp.
- (push (cons (rx (literal tmpname)) (cdr elt)) result)))))
+ (push (cons (tramp-compat-rx (literal tmpname)) (cdr elt)) result)))))
(defun tramp-run-real-handler (operation args)
"Invoke normal file name handler for OPERATION.
#'file-name-sans-extension
(directory-files
dir nil (rx bos "tramp" (+ nonl) ".el" (? "c") eos)))))
- (files-regexp (rx bol (regexp (regexp-opt files)) eol)))
+ (files-regexp (tramp-compat-rx bol (regexp (regexp-opt files)) eol)))
(mapatoms
(lambda (atom)
(when (and (functionp atom)
;; Suppress hop from completion.
(when (string-match
- (rx (regexp tramp-prefix-regexp)
- (group (+ (regexp tramp-remote-file-name-spec-regexp)
- (regexp tramp-postfix-hop-regexp))))
+ (tramp-compat-rx
+ (regexp tramp-prefix-regexp)
+ (group (+ (regexp tramp-remote-file-name-spec-regexp)
+ (regexp tramp-postfix-hop-regexp))))
fullname)
(setq hop (match-string 1 fullname)
fullname (replace-match "" nil nil fullname 1)))
(let (;; "/method" "/[method"
(tramp-completion-file-name-structure1
(list
- (rx (regexp tramp-prefix-regexp)
- (group (? (regexp tramp-completion-method-regexp))) eol)
+ (tramp-compat-rx
+ (regexp tramp-prefix-regexp)
+ (group (? (regexp tramp-completion-method-regexp))) eol)
1 nil nil nil))
;; "/method:user" "/[method/user"
(tramp-completion-file-name-structure2
(list
- (rx (regexp tramp-prefix-regexp)
- (group (regexp tramp-method-regexp))
- (regexp tramp-postfix-method-regexp)
- (group (? (regexp tramp-user-regexp))) eol)
+ (tramp-compat-rx
+ (regexp tramp-prefix-regexp)
+ (group (regexp tramp-method-regexp))
+ (regexp tramp-postfix-method-regexp)
+ (group (? (regexp tramp-user-regexp))) eol)
1 2 nil nil))
;; "/method:host" "/[method/host"
(tramp-completion-file-name-structure3
(list
- (rx (regexp tramp-prefix-regexp)
- (group (regexp tramp-method-regexp))
- (regexp tramp-postfix-method-regexp)
- (group (? (regexp tramp-host-regexp))) eol)
+ (tramp-compat-rx
+ (regexp tramp-prefix-regexp)
+ (group (regexp tramp-method-regexp))
+ (regexp tramp-postfix-method-regexp)
+ (group (? (regexp tramp-host-regexp))) eol)
1 nil 2 nil))
;; "/method:[ipv6" "/[method/ipv6"
(tramp-completion-file-name-structure4
(list
- (rx (regexp tramp-prefix-regexp)
- (group (regexp tramp-method-regexp))
- (regexp tramp-postfix-method-regexp)
- (regexp tramp-prefix-ipv6-regexp)
- (group (? (regexp tramp-ipv6-regexp))) eol)
+ (tramp-compat-rx
+ (regexp tramp-prefix-regexp)
+ (group (regexp tramp-method-regexp))
+ (regexp tramp-postfix-method-regexp)
+ (regexp tramp-prefix-ipv6-regexp)
+ (group (? (regexp tramp-ipv6-regexp))) eol)
1 nil 2 nil))
;; "/method:user@host" "/[method/user@host"
(tramp-completion-file-name-structure5
(list
- (rx (regexp tramp-prefix-regexp)
- (group (regexp tramp-method-regexp))
- (regexp tramp-postfix-method-regexp)
- (group (regexp tramp-user-regexp))
- (regexp tramp-postfix-user-regexp)
- (group (? (regexp tramp-host-regexp))) eol)
+ (tramp-compat-rx
+ (regexp tramp-prefix-regexp)
+ (group (regexp tramp-method-regexp))
+ (regexp tramp-postfix-method-regexp)
+ (group (regexp tramp-user-regexp))
+ (regexp tramp-postfix-user-regexp)
+ (group (? (regexp tramp-host-regexp))) eol)
1 2 3 nil))
;; "/method:user@[ipv6" "/[method/user@ipv6"
(tramp-completion-file-name-structure6
(list
- (rx (regexp tramp-prefix-regexp)
- (group (regexp tramp-method-regexp))
- (regexp tramp-postfix-method-regexp)
- (group (regexp tramp-user-regexp))
- (regexp tramp-postfix-user-regexp)
- (regexp tramp-prefix-ipv6-regexp)
- (group (? (regexp tramp-ipv6-regexp))) eol)
+ (tramp-compat-rx
+ (regexp tramp-prefix-regexp)
+ (group (regexp tramp-method-regexp))
+ (regexp tramp-postfix-method-regexp)
+ (group (regexp tramp-user-regexp))
+ (regexp tramp-postfix-user-regexp)
+ (regexp tramp-prefix-ipv6-regexp)
+ (group (? (regexp tramp-ipv6-regexp))) eol)
1 2 3 nil)))
(delq
nil
Either user or host may be nil."
(let (result
(regexp
- (rx bol (group (regexp tramp-host-regexp))
- (? (+ blank) (group (regexp tramp-user-regexp))))))
+ (tramp-compat-rx
+ bol (group (regexp tramp-host-regexp))
+ (? (+ blank) (group (regexp tramp-user-regexp))))))
(when (re-search-forward regexp (line-end-position) t)
(setq result (append (list (match-string 2) (match-string 1)))))
(forward-line 1)
(defun tramp-parse-shosts-group ()
"Return a (user host) tuple allowed to access.
User is always nil."
- (tramp-parse-group (rx bol (group (regexp tramp-host-regexp))) 1 ","))
+ (tramp-parse-group
+ (tramp-compat-rx bol (group (regexp tramp-host-regexp))) 1 ","))
(defun tramp-parse-sconfig (filename)
"Return a list of (user host) tuples allowed to access.
"Return a (user host) tuple allowed to access.
User is always nil."
(tramp-parse-group
- (rx (| (: bol (* blank) "Host")
- (: bol (+ nonl)) ;; ???
- (group (regexp tramp-host-regexp))))
+ (tramp-compat-rx
+ (| (: bol (* blank) "Host")
+ (: bol (+ nonl)) ;; ???
+ (group (regexp tramp-host-regexp))))
1 (rx blank)))
;; Generic function.
User is always nil."
(tramp-parse-shostkeys-sknownhosts
dirname
- (rx bol "key_" (+ digit) "_" (group (regexp tramp-host-regexp)) ".pub" eol)))
+ (tramp-compat-rx
+ bol "key_" (+ digit) "_" (group (regexp tramp-host-regexp)) ".pub" eol)))
(defun tramp-parse-sknownhosts (dirname)
"Return a list of (user host) tuples allowed to access.
User is always nil."
(tramp-parse-shostkeys-sknownhosts
dirname
- (rx bol (group (regexp tramp-host-regexp))
- ".ssh-" (| "dss" "rsa") ".pub" eol)))
+ (tramp-compat-rx
+ bol (group (regexp tramp-host-regexp)) ".ssh-" (| "dss" "rsa") ".pub" eol)))
(defun tramp-parse-hosts (filename)
"Return a list of (user host) tuples allowed to access.
"Return a (user host) tuple allowed to access.
User is always nil."
(tramp-parse-group
- (rx bol (group (| (regexp tramp-ipv6-regexp) (regexp tramp-host-regexp))))
+ (tramp-compat-rx
+ bol (group (| (regexp tramp-ipv6-regexp) (regexp tramp-host-regexp))))
1 (rx blank)))
(defun tramp-parse-passwd (filename)
"Return a (user host) tuple allowed to access.
Host is always \"localhost\"."
(let (result
- (regexp (rx bol (group (regexp tramp-user-regexp)) ":")))
+ (regexp (tramp-compat-rx bol (group (regexp tramp-user-regexp)) ":")))
(when (re-search-forward regexp (line-end-position) t)
(setq result (list (match-string 1) "localhost")))
(forward-line 1)
(tramp-parse-putty-group registry-or-dirname)))))
;; UNIX case.
(tramp-parse-shostkeys-sknownhosts
- registry-or-dirname (rx bol (group (regexp tramp-host-regexp)) eol))))
+ registry-or-dirname
+ (tramp-compat-rx bol (group (regexp tramp-host-regexp)) eol))))
(defun tramp-parse-putty-group (registry)
"Return a (user host) tuple allowed to access.
User is always nil."
(let (result
- (regexp (rx (literal registry) "\\" (group (+ nonl)))))
+ (regexp (tramp-compat-rx (literal registry) "\\" (group (+ nonl)))))
(when (re-search-forward regexp (line-end-position) t)
(setq result (list nil (match-string 1))))
(forward-line 1)
;; not support tilde expansion. But users could declare a
;; respective connection property. (Bug#53847)
(when (string-match
- (rx bos "~" (group (* (not (any "/")))) (group (* nonl)) eos)
+ (tramp-compat-rx bos "~" (group (* (not "/"))) (group (* nonl)) eos)
localname)
(let ((uname (match-string 1 localname))
(fname (match-string 2 localname))
(and
completion-ignored-extensions
(string-match-p
- (rx (regexp (regexp-opt completion-ignored-extensions)) eos)
+ (tramp-compat-rx
+ (regexp (regexp-opt completion-ignored-extensions)) eos)
x)
;; We remember the hit.
(push x hits-ignored-extensions))))))
tramp-prefix-format proxy tramp-postfix-host-format))
(entry
(list (and (stringp host-port)
- (rx bol (literal host-port) eol))
+ (tramp-compat-rx bol (literal host-port) eol))
(and (stringp user-domain)
- (rx bol (literal user-domain) eol))
+ (tramp-compat-rx bol (literal user-domain) eol))
(propertize proxy 'tramp-ad-hoc t))))
(tramp-message vec 5 "Add %S to `tramp-default-proxies-alist'" entry)
;; Add the hop.
(setq tramp-default-proxies-alist saved-tdpa)
(tramp-user-error
vec "Host name `%s' does not match `%s'" host previous-host))
- (setq previous-host (rx bol (literal host) eol)))))
+ (setq previous-host (tramp-compat-rx bol (literal host) eol)))))
;; Result.
target-alist))
(tramp-flush-directory-properties vec "/"))
(when (buffer-live-p buf)
(with-current-buffer buf
- (when (and prompt (tramp-search-regexp (rx (literal prompt))))
+ (when (and prompt
+ (tramp-search-regexp (tramp-compat-rx (literal prompt))))
(delete-region (point) (point-max))))))))
(defun tramp-get-inode (vec)
(while candidates
(goto-char (point-min))
(if (string-match-p
- (rx bol (literal (car candidates)) (? "\r") eol)
+ (tramp-compat-rx bol (literal (car candidates)) (? "\r") eol)
(buffer-string))
(setq locale (car candidates)
candidates nil)
(let* ((pr (car alist))
(from (car pr))
(to (cdr pr)))
- (while (string-match (rx (literal from)) string)
+ (while (string-match (tramp-compat-rx (literal from)) string)
(setq string (replace-match to t t string)))
(setq alist (cdr alist))))
string))
(string= (substring result 0 2) "\\~"))
(setq result (substring result 1)))
(replace-regexp-in-string
- (rx "\\" (literal tramp-rsh-end-of-line))
+ (tramp-compat-rx "\\" (literal tramp-rsh-end-of-line))
(format "'%s'" tramp-rsh-end-of-line) result)))))
;;; Signal handling. This works for remote processes, which have set
(insert-directory tramp-archive-test-archive nil)
(goto-char (point-min))
(should
- (looking-at-p (rx (literal tramp-archive-test-archive)))))
+ (looking-at-p
+ (tramp-compat-rx (literal tramp-archive-test-archive)))))
(with-temp-buffer
(insert-directory tramp-archive-test-archive "-al")
(goto-char (point-min))
(should
(looking-at-p
- (rx bol (+ nonl) blank (literal tramp-archive-test-archive) eol))))
+ (tramp-compat-rx
+ bol (+ nonl) blank (literal tramp-archive-test-archive) eol))))
(with-temp-buffer
(insert-directory
(file-name-as-directory tramp-archive-test-archive)
(dolist (file `("/mock::foo" ,(concat tramp-archive-test-archive "foo")))
(should
(string-match
- (rx "tramp-archive loaded: "
- (literal (symbol-name
- (tramp-archive-file-name-p default-directory)))
- (+ ascii)
- "tramp-archive loaded: "
- (literal (symbol-name
- (or (tramp-archive-file-name-p default-directory)
- (and enabled (tramp-archive-file-name-p file))))))
+ (tramp-compat-rx
+ "tramp-archive loaded: "
+ (literal (symbol-name
+ (tramp-archive-file-name-p default-directory)))
+ (+ ascii)
+ "tramp-archive loaded: "
+ (literal (symbol-name
+ (or (tramp-archive-file-name-p default-directory)
+ (and enabled (tramp-archive-file-name-p file))))))
(shell-command-to-string
(format
"%s -batch -Q -L %s --eval %s --eval %s"
(dolist (tae '(t nil))
(should
(string-match
- (rx "tramp-archive loaded: nil" (+ ascii)
- "tramp-archive loaded: nil" (+ ascii)
- "tramp-archive loaded: " (literal (symbol-name tae)))
+ (tramp-compat-rx
+ "tramp-archive loaded: nil" (+ ascii)
+ "tramp-archive loaded: nil" (+ ascii)
+ "tramp-archive loaded: " (literal (symbol-name tae)))
(shell-command-to-string
(format
"%s -batch -Q -L %s --eval %s"
;; Check `directory-abbrev-alist' abbreviation.
(let ((directory-abbrev-alist
- `((,(rx bos (literal home-dir) "/foo")
+ `((,(tramp-compat-rx bos (literal home-dir) "/foo")
. ,(concat home-dir "/f"))
- (,(rx bos (literal remote-host) "/nowhere")
+ (,(tramp-compat-rx bos (literal remote-host) "/nowhere")
. ,(concat remote-host "/nw")))))
(should (equal (abbreviate-file-name (concat home-dir "/foo/bar"))
(concat remote-host-nohop "~/f/bar")))
(string-match-p
(if (and (null noninteractive)
(or (eq visit t) (null visit) (stringp visit)))
- (rx bol "Wrote " (literal tmp-name) "\n" eos)
+ (tramp-compat-rx
+ bol "Wrote " (literal tmp-name) "\n" eos)
(rx bos))
tramp--test-messages))))))
(with-temp-buffer
(insert-directory tmp-name1 nil)
(goto-char (point-min))
- (should (looking-at-p (rx (literal tmp-name1)))))
+ (should (looking-at-p (tramp-compat-rx (literal tmp-name1)))))
(with-temp-buffer
(insert-directory (file-name-as-directory tmp-name1) nil)
(goto-char (point-min))
(should
(looking-at-p
- (rx (literal (file-name-as-directory tmp-name1))))))
+ (tramp-compat-rx (literal (file-name-as-directory tmp-name1))))))
(with-temp-buffer
(insert-directory tmp-name1 "-al")
(goto-char (point-min))
(should
- (looking-at-p (rx bol (+ nonl) blank (literal tmp-name1) eol))))
+ (looking-at-p
+ (tramp-compat-rx bol (+ nonl) blank (literal tmp-name1) eol))))
(with-temp-buffer
(insert-directory (file-name-as-directory tmp-name1) "-al")
(goto-char (point-min))
(should
(looking-at-p
- (rx bol (+ nonl) blank (literal tmp-name1) "/" eol))))
+ (tramp-compat-rx
+ bol (+ nonl) blank (literal tmp-name1) "/" eol))))
(with-temp-buffer
(insert-directory
(file-name-as-directory tmp-name1) "-al" nil 'full-directory-p)
(goto-char (point-min))
(should
(re-search-forward
- (rx (literal
- (file-relative-name
- tmp-name1 ert-remote-temporary-file-directory)))))
+ (tramp-compat-rx
+ (literal
+ (file-relative-name
+ tmp-name1 ert-remote-temporary-file-directory)))))
(goto-char (point-min))
(should
(re-search-forward
- (rx (literal
- (file-relative-name
- tmp-name2 ert-remote-temporary-file-directory))))))
+ (tramp-compat-rx
+ (literal
+ (file-relative-name
+ tmp-name2 ert-remote-temporary-file-directory))))))
(kill-buffer buffer)
;; Check for expanded directory and file names.
(goto-char (point-min))
(should
(re-search-forward
- (rx (literal
- (file-relative-name
- tmp-name3 ert-remote-temporary-file-directory)))))
+ (tramp-compat-rx
+ (literal
+ (file-relative-name
+ tmp-name3 ert-remote-temporary-file-directory)))))
(goto-char (point-min))
(should
(re-search-forward
- (rx (literal
- (file-relative-name
- tmp-name4
- ert-remote-temporary-file-directory))))))
+ (tramp-compat-rx
+ (literal
+ (file-relative-name
+ tmp-name4
+ ert-remote-temporary-file-directory))))))
(kill-buffer buffer)
;; Check for special characters.
(goto-char (point-min))
(should
(re-search-forward
- (rx (literal
- (file-relative-name
- tmp-name3 ert-remote-temporary-file-directory)))))
+ (tramp-compat-rx
+ (literal
+ (file-relative-name
+ tmp-name3 ert-remote-temporary-file-directory)))))
(goto-char (point-min))
(should
(re-search-forward
- (rx (literal
- (file-relative-name
- tmp-name4
- ert-remote-temporary-file-directory))))))
+ (tramp-compat-rx
+ (literal
+ (file-relative-name
+ tmp-name4
+ ert-remote-temporary-file-directory))))))
(kill-buffer buffer))
;; Cleanup.
(cons '(nil "perl" nil)
tramp-connection-properties)))
(progn
+ ;; `ert-test-result-duration' exists since Emacs 27. It
+ ;; doesn't hurt to call it unconditionally, because
+ ;; `skip-unless' hides the error.
(skip-unless (< (ert-test-result-duration result) 300))
(funcall (ert-test-body ert-test)))
(ert-skip (format "Test `%s' must run before" ',test)))))
(nil "id" nil))
tramp-connection-properties)))
(progn
+ ;; `ert-test-result-duration' exists since Emacs 27. It
+ ;; doesn't hurt to call it unconditionally, because
+ ;; `skip-unless' hides the error.
(skip-unless (< (ert-test-result-duration result) 300))
(funcall (ert-test-body ert-test)))
(ert-skip (format "Test `%s' must run before" ',test)))))
(nil "readlink" nil))
tramp-connection-properties)))
(progn
+ ;; `ert-test-result-duration' exists since Emacs 27. It
+ ;; doesn't hurt to call it unconditionally, because
+ ;; `skip-unless' hides the error.
(skip-unless (< (ert-test-result-duration result) 300))
(funcall (ert-test-body ert-test)))
(ert-skip (format "Test `%s' must run before" ',test)))))
;; Variable is set.
(should
(string-match-p
- (rx (literal envvar))
+ (tramp-compat-rx (literal envvar))
(funcall this-shell-command-to-string "set"))))
(unless (tramp-direct-async-process-p)
;; Variable is unset.
(should-not
(string-match-p
- (rx (literal envvar))
+ (tramp-compat-rx (literal envvar))
;; We must remove PS1, the output is truncated otherwise.
;; We must suppress "_=VAR...".
(funcall
:body nil :tags '(:tramp-asynchronous-processes))))
;; tramp-adb.el cannot apply multi-byte commands.
(not (and (tramp--test-adb-p)
- (string-match-p (rx multibyte) default-directory)))))
+ (string-match-p (tramp-compat-rx multibyte) default-directory)))))
(defun tramp--test-crypt-p ()
"Check, whether the remote directory is encrypted."
(should
(string-equal
(caar (directory-files-and-attributes
- file1 nil (rx (literal elt1))))
+ file1 nil (tramp-compat-rx (literal elt1))))
elt1))
(should
(string-equal
(funcall
(if quoted #'tramp-compat-file-name-quote #'identity)
(cadr (car (directory-files-and-attributes
- file1 nil (rx (literal elt1))))))
+ file1 nil (tramp-compat-rx (literal elt1))))))
(file-remote-p (file-truename file2) 'localname)))
(delete-file file3)
(should-not (file-exists-p file3))))
(goto-char (point-min))
(should
(re-search-forward
- (rx bol (literal envvar)
- "=" (literal (getenv envvar)) eol))))))))
+ (tramp-compat-rx
+ bol (literal envvar)
+ "=" (literal (getenv envvar)) eol))))))))
;; Cleanup.
(ignore-errors (kill-buffer buffer))
(dolist (tm '(t nil))
(should
(string-match-p
- (rx "Tramp loaded: nil" (+ (any "\n\r"))
- "Tramp loaded: nil" (+ (any "\n\r"))
- "Tramp loaded: " (literal (symbol-name tm)) (+ (any "\n\r")))
+ (tramp-compat-rx
+ "Tramp loaded: nil" (+ (any "\n\r"))
+ "Tramp loaded: nil" (+ (any "\n\r"))
+ "Tramp loaded: " (literal (symbol-name tm)) (+ (any "\n\r")))
(shell-command-to-string
(format
"%s -batch -Q -L %s --eval %s"
(tramp-cleanup-all-connections))"))
(should
(string-match-p
- (rx "Loading "
- (literal
- (expand-file-name
- "tramp-cmds" (file-name-directory (locate-library "tramp")))))
+ (tramp-compat-rx
+ "Loading "
+ (literal
+ (expand-file-name
+ "tramp-cmds" (file-name-directory (locate-library "tramp")))))
(shell-command-to-string
(format
"%s -batch -Q -L %s -l tramp-sh --eval %s"
;; * file-in-directory-p
;; * file-name-case-insensitive-p
;; * tramp-get-remote-gid
+;; * tramp-get-remote-groups
;; * tramp-get-remote-uid
;; * tramp-set-file-uid-gid