diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2022-08-26 16:19:47 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2022-08-26 16:19:47 +0200 |
commit | be2e6228f8c9c57d2809bdd953d065ebfc63d4c4 (patch) | |
tree | 8f1ecc68c987f88be3fbfd9eb0bd6b24a2483df5 /lisp/net/tramp-cmds.el | |
parent | 4cb31b19353d3d1f8629d7c7b55aff2445efc02a (diff) | |
download | emacs-be2e6228f8c9c57d2809bdd953d065ebfc63d4c4.tar.gz |
Use `rx' in Tramp where possible
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-archive.el:
* lisp/net/tramp-cache.el:
* lisp/net/tramp-cmds.el:
* lisp/net/tramp-compat.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-ftp.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-integration.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Use `rx' where possible.
* lisp/net/tramp-adb.el (tramp-adb-handle-set-file-times):
Use `eval-when-compile'.
(tramp-adb-maybe-open-connection): Use file-property for "/". Use
`eval-when-compile'.
* lisp/net/tramp-cmds.el (mm-7bit-chars): Declare.
(tramp-reporter-dump-variable): Simplify point movement.
* lisp/net/tramp-gvfs.el (tramp-dbus-function): Fix typo.
(tramp-zeroconf-parse-device-names): Use `tramp-prefix-port-format'.
* lisp/net/tramp-sh.el (tramp-open-shell, tramp-find-shell):
Use `eval-when-compile'. Improve sanity check.
* lisp/net/tramp.el (tramp-prefix-format, tramp-prefix-regexp)
(tramp-method-regexp, tramp-postfix-method-format)
(tramp-postfix-method-regexp, tramp-prefix-ipv6-format)
(tramp-prefix-ipv6-regexp, tramp-postfix-ipv6-format)
(tramp-postfix-ipv6-regexp, tramp-postfix-host-format)
(tramp-postfix-host-regexp, tramp-remote-file-name-spec-regexp)
(tramp-file-name-structure, tramp-file-name-regexp)
(tramp-completion-method-regexp)
(tramp-completion-file-name-regexp): Declare.
(tramp-set-syntax): Set also `tramp-completion-method-regexp'.
(tramp-volume-letter-regexp, tramp-completion-method-regexp-alist):
New defconsts.
(tramp-build-completion-method-regexp): New defun.
(tramp-completion-method-regexp): New defvar.
(tramp-completion-file-name-regexp-default)
(tramp-completion-file-name-regexp-simplified)
(tramp-completion-file-name-regexp-separate)
(tramp-completion-file-name-regexp-alist): Remove.
(tramp-build-completion-file-name-regexp): Rwrite.
(tramp-make-tramp-file-name): Use `tramp-archive-method'.
(tramp-handle-file-directory-p): Ignore errors.
(tramp-handle-find-backup-file-name, tramp-handle-lock-file)
(tramp-handle-make-auto-save-file-name): Use `eval-when-compile'.
* test/lisp/net/tramp-archive-tests.el:
* test/lisp/net/tramp-tests.el: Use `rx' where possible.
(tramp-test01-file-name-syntax): Adapt test.
Diffstat (limited to 'lisp/net/tramp-cmds.el')
-rw-r--r-- | lisp/net/tramp-cmds.el | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/lisp/net/tramp-cmds.el b/lisp/net/tramp-cmds.el index b2a68fc5eba..a7ac1352665 100644 --- a/lisp/net/tramp-cmds.el +++ b/lisp/net/tramp-cmds.el @@ -34,6 +34,7 @@ (declare-function mml-mode "mml") (declare-function mml-insert-empty-tag "mml") (declare-function reporter-dump-variable "reporter") +(defvar mm-7bit-chars) (defvar reporter-eval-buffer) (defvar reporter-prompt-for-summary-p) @@ -502,7 +503,7 @@ This is needed if there are compatibility problems." ((dir (tramp-compat-funcall 'package-desc-dir (car (alist-get 'tramp (bound-and-true-p package-alist)))))) - (dolist (elc (directory-files dir 'full "\\.elc\\'")) + (dolist (elc (directory-files dir 'full (rx ".elc" eos))) (delete-file elc)) (with-current-buffer (get-buffer-create byte-compile-log-buffer) (let ((inhibit-read-only t)) @@ -604,7 +605,7 @@ buffer in your bug report. ;; There are non-7bit characters to be masked. (when (and (stringp val) (string-match-p - (concat "[^" (bound-and-true-p mm-7bit-chars) "]") val)) + (rx-to-string `(not (any ,mm-7bit-chars))) val)) (with-current-buffer reporter-eval-buffer (set varsym `(decode-coding-string @@ -613,20 +614,21 @@ buffer in your bug report. 'raw-text))))) ;; Dump variable. - (reporter-dump-variable varsym mailbuf) + (goto-char (point-max)) + (save-excursion + (reporter-dump-variable varsym mailbuf)) (unless (hash-table-p val) ;; Remove string quotation. - (forward-line -1) (when (looking-at - (concat "\\(^.*\\)" "\"" ;; \1 " - "\\((base64-decode-string \\)" "\\\\" ;; \2 \ - "\\(\".*\\)" "\\\\" ;; \3 \ - "\\(\")\\)" "\"$")) ;; \4 " + (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")) - (forward-line 1)) + (insert " ;; Variable encoded due to non-printable characters.\n"))) + (goto-char (point-max)) ;; Reset VARSYM to old value. (with-current-buffer reporter-eval-buffer @@ -656,21 +658,27 @@ buffer in your bug report. (erase-buffer) (insert (format "\n;; %s\n(setq-local\n" (buffer-name buffer))) (lisp-indent-line) - (dolist - (varsym - (sort - (append - (mapcar - #'intern - (all-completions "tramp-" (buffer-local-variables buffer))) - ;; Non-tramp variables of interest. - '(connection-local-variables-alist default-directory)) - #'string<)) - (reporter-dump-variable varsym elbuf)) + (dolist (varsym + (sort + (append + (mapcar + #'intern + (all-completions "tramp-" (buffer-local-variables buffer))) + ;; Non-tramp variables of interest. + '(connection-local-variables-alist default-directory)) + #'string<)) + (reporter-dump-variable varsym elbuf)) (lisp-indent-line) (insert ")\n")) (insert-buffer-substring elbuf))) + ;; Beautify encoded values. + (goto-char (point-min)) + (while (re-search-forward + (rx "'" (group "(decode-coding-string")) nil 'noerror) + (replace-match "\\1")) + (goto-char (point-max)) + ;; Dump load-path shadows. (insert "\nload-path shadows:\n==================\n") (ignore-errors @@ -683,7 +691,7 @@ buffer in your bug report. (eq major-mode 'message-mode) (bound-and-true-p mml-mode)) - (let ((tramp-buf-regexp "\\*\\(debug \\)?tramp/") + (let ((tramp-buf-regexp (rx "*" (? "debug ") "tramp/")) (buffer-list (tramp-list-tramp-buffers)) (curbuf (current-buffer))) @@ -694,7 +702,7 @@ buffer in your bug report. (setq buffer-read-only nil) (goto-char (point-min)) (while (not (eobp)) - (if (re-search-forward tramp-buf-regexp (line-end-position) t) + (if (re-search-forward tramp-buf-regexp (line-end-position) t) (forward-line 1) (forward-line 0) (let ((start (point))) |