From: Michael Albinus Date: Thu, 25 May 2017 08:04:12 +0000 (+0200) Subject: Switch Tramp to cl-lib X-Git-Tag: emacs-26.0.90~521^2~273 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=1a9ce7c54e99d80fb515a33edbeeb75fd3239526;p=emacs.git Switch Tramp to cl-lib * lisp/net/tramp-compat.el (cl-lib): Require it rather than cl. * lisp/net/tramp-ftp.el: Don't require cl. * lisp/net/tramp-gvfs.el: Don't require cl. (tramp-gvfs-handler-mounted-unmounted) (tramp-gvfs-connection-mounted-p): Use `cl-*' macros. * lisp/net/tramp-sh.el: Don't require cl. (tramp-set-file-uid-gid): Use `shell-quote-argument'. (tramp-sh-gvfs-monitor-dir-process-filter) (tramp-sh-inotifywait-process-filter): Use `cl-*' macros. * lisp/net/tramp-smb.el: Don't require cl. (tramp-smb-read-file-entry): Use `cl-*' macros. * lisp/net/tramp.el (cl-lib): Require it rather than cl. (tramp-parse-file, tramp-parse-shostkeys-sknownhosts) (tramp-parse-passwd, tramp-parse-etc-group) (tramp-parse-putty): Use `cl-*' macros. --- diff --git a/lisp/net/tramp-compat.el b/lisp/net/tramp-compat.el index 53266e806c0..392a28c59de 100644 --- a/lisp/net/tramp-compat.el +++ b/lisp/net/tramp-compat.el @@ -29,12 +29,9 @@ ;;; Code: -;; Pacify byte-compiler. -(eval-when-compile - (require 'cl)) - (require 'auth-source) (require 'advice) +(require 'cl-lib) (require 'custom) (require 'format-spec) (require 'parse-time) diff --git a/lisp/net/tramp-ftp.el b/lisp/net/tramp-ftp.el index 44a4ccadaca..8e489eee801 100644 --- a/lisp/net/tramp-ftp.el +++ b/lisp/net/tramp-ftp.el @@ -32,7 +32,6 @@ ;; Pacify byte-compiler. (eval-when-compile - (require 'cl) (require 'custom)) (defvar ange-ftp-ftp-name-arg) (defvar ange-ftp-ftp-name-res) diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index ad9bd819c02..57a135139a5 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el @@ -106,7 +106,6 @@ ;; Pacify byte-compiler. (eval-when-compile - (require 'cl) (require 'custom)) ;;;###tramp-autoload @@ -1386,9 +1385,9 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"." ;; elements. (while (stringp (car elt)) (setq elt (cdr elt))) (let* ((fuse-mountpoint (tramp-gvfs-dbus-byte-array-to-string (cadr elt))) - (mount-spec (caddr elt)) + (mount-spec (cl-caddr elt)) (default-location (tramp-gvfs-dbus-byte-array-to-string - (cadddr elt))) + (cl-cadddr elt))) (method (tramp-gvfs-dbus-byte-array-to-string (cadr (assoc "type" (cadr mount-spec))))) (user (tramp-gvfs-dbus-byte-array-to-string @@ -1472,9 +1471,9 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"." (while (stringp (car elt)) (setq elt (cdr elt))) (let* ((fuse-mountpoint (tramp-gvfs-dbus-byte-array-to-string (cadr elt))) - (mount-spec (caddr elt)) + (mount-spec (cl-caddr elt)) (default-location (tramp-gvfs-dbus-byte-array-to-string - (cadddr elt))) + (cl-cadddr elt))) (method (tramp-gvfs-dbus-byte-array-to-string (cadr (assoc "type" (cadr mount-spec))))) (user (tramp-gvfs-dbus-byte-array-to-string diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 4b89c173471..84782a4c7f3 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el @@ -31,7 +31,6 @@ ;; Pacify byte-compiler. (eval-when-compile - (require 'cl) (require 'dired)) (declare-function dired-remove-file "dired-aux") @@ -1557,7 +1556,7 @@ be non-negative integers." (gid (or (and (natnump gid) gid) (tramp-get-local-gid 'integer)))) (tramp-call-process nil "chown" nil nil nil - (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))))) + (format "%d:%d" uid gid) (shell-quote-argument filename))))))) (defun tramp-remote-selinux-p (vec) "Check, whether SELINUX is enabled on the remote host." @@ -3674,13 +3673,13 @@ file-notify events." (when file1 (concat remote-prefix file1))))) (setq string (replace-match "" nil nil string)) ;; Remove watch when file or directory to be watched is deleted. - (when (and (member (caadr object) '(moved deleted)) + (when (and (member (cl-caadr object) '(moved deleted)) (string-equal file (process-get proc 'watch-name))) (delete-process proc)) ;; Usually, we would add an Emacs event now. Unfortunately, ;; `unread-command-events' does not accept several events at ;; once. Therefore, we apply the handler directly. - (when (member (caadr object) events) + (when (member (cl-caadr object) events) (tramp-compat-funcall 'file-notify-handle-event `(file-notify ,object file-notify-callback))))) @@ -3714,12 +3713,12 @@ file-notify events." (split-string (match-string 1 line) "," 'omit)) (match-string 3 line)))) ;; Remove watch when file or directory to be watched is deleted. - (when (member (caadr object) '(move-self delete-self ignored)) + (when (member (cl-caadr object) '(move-self delete-self ignored)) (delete-process proc)) ;; Usually, we would add an Emacs event now. Unfortunately, ;; `unread-command-events' does not accept several events at ;; once. Therefore, we apply the handler directly. - (when (member (caadr object) events) + (when (member (cl-caadr object) events) (tramp-compat-funcall 'file-notify-handle-event `(file-notify ,object file-notify-callback))))))) diff --git a/lisp/net/tramp-smb.el b/lisp/net/tramp-smb.el index 7b2a1ba874d..88db8eaf0e1 100644 --- a/lisp/net/tramp-smb.el +++ b/lisp/net/tramp-smb.el @@ -29,10 +29,6 @@ (require 'tramp) -;; Pacify byte-compiler. -(eval-when-compile - (require 'cl)) - ;; Define SMB method ... ;;;###tramp-autoload (defconst tramp-smb-method "smb" @@ -1655,13 +1651,13 @@ Result is the list (LOCALNAME MODE SIZE MTIME)." size 0)) ;; Real listing. - (block nil + (cl-block nil ;; year. (if (string-match "\\([0-9]+\\)$" line) (setq year (string-to-number (match-string 1 line)) line (substring line 0 -5)) - (return)) + (cl-return)) ;; time. (if (string-match "\\([0-9]+\\):\\([0-9]+\\):\\([0-9]+\\)$" line) @@ -1669,24 +1665,24 @@ Result is the list (LOCALNAME MODE SIZE MTIME)." min (string-to-number (match-string 2 line)) sec (string-to-number (match-string 3 line)) line (substring line 0 -9)) - (return)) + (cl-return)) ;; day. (if (string-match "\\([0-9]+\\)$" line) (setq day (string-to-number (match-string 1 line)) line (substring line 0 -3)) - (return)) + (cl-return)) ;; month. (if (string-match "\\(\\w+\\)$" line) (setq month (match-string 1 line) line (substring line 0 -4)) - (return)) + (cl-return)) ;; weekday. (if (string-match "\\(\\w+\\)$" line) (setq line (substring line 0 -5)) - (return)) + (cl-return)) ;; size. (if (string-match "\\([0-9]+\\)$" line) @@ -1695,7 +1691,7 @@ Result is the list (LOCALNAME MODE SIZE MTIME)." (when (string-match "\\([ADHRSV]+\\)" (substring line length)) (setq length (+ length (match-end 0)))) (setq line (substring line 0 length))) - (return)) + (cl-return)) ;; mode: ARCH, DIR, HIDDEN, RONLY, SYSTEM, VOLID. (if (string-match "\\([ADHRSV]+\\)?$" line) @@ -1708,12 +1704,12 @@ Result is the list (LOCALNAME MODE SIZE MTIME)." (lambda (_x) "") " " (concat "r" (if (string-match "R" mode) "-" "w") "x")))) line (substring line 0 -6)) - (return)) + (cl-return)) ;; localname. (if (string-match "^\\s-+\\(\\S-\\(.*\\S-\\)?\\)\\s-*$" line) (setq localname (match-string 1 line)) - (return)))) + (cl-return)))) (when (and localname mode size) (setq mtime diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index b97a7a877cd..a1cd90bec79 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -58,8 +58,7 @@ (require 'tramp-compat) ;; Pacify byte-compiler. -(eval-when-compile - (require 'cl)) +(require 'cl-lib) (defvar auto-save-file-name-transforms) (defvar eshell-path-env) (defvar ls-lisp-use-insert-directory-program) @@ -1134,8 +1133,8 @@ calling HANDLER.") ;; internal data structure. Convenience functions for internal ;; data structure. -;; The basic structure for remote file names. We use a list, -;; otherwise the test in `tramp-cache-data' fails. +;; The basic structure for remote file names. We use a list :type, +;; otherwise the persistent data are not read in tramp-cache.el. (cl-defstruct (tramp-file-name (:type list) :named) method user domain host port localname hop) @@ -2588,7 +2587,7 @@ User is always nil." (with-temp-buffer (insert-file-contents filename) (goto-char (point-min)) - (loop while (not (eobp)) collect (funcall function)))))) + (cl-loop while (not (eobp)) collect (funcall function)))))) ;;;###tramp-autoload (defun tramp-parse-rhosts (filename) @@ -2640,9 +2639,10 @@ User is always nil." ;; `default-directory' is remote. (let* ((default-directory (tramp-compat-temporary-file-directory)) (files (and (file-directory-p dirname) (directory-files dirname)))) - (loop for f in files - when (and (not (string-match "^\\.\\.?$" f)) (string-match regexp f)) - collect (list nil (match-string 1 f))))) + (cl-loop + for f in files + when (and (not (string-match "^\\.\\.?$" f)) (string-match regexp f)) + collect (list nil (match-string 1 f))))) ;;;###tramp-autoload (defun tramp-parse-shostkeys (dirname) @@ -2680,8 +2680,8 @@ Host is always \"localhost\"." (with-temp-buffer (when (zerop (tramp-call-process nil "getent" nil t nil "passwd")) (goto-char (point-min)) - (loop while (not (eobp)) collect - (tramp-parse-etc-group-group)))) + (cl-loop while (not (eobp)) collect + (tramp-parse-etc-group-group)))) (tramp-parse-file filename 'tramp-parse-passwd-group)))) (defun tramp-parse-passwd-group () @@ -2703,8 +2703,8 @@ Host is always \"localhost\"." (with-temp-buffer (when (zerop (tramp-call-process nil "getent" nil t nil "group")) (goto-char (point-min)) - (loop while (not (eobp)) collect - (tramp-parse-etc-group-group)))) + (cl-loop while (not (eobp)) collect + (tramp-parse-etc-group-group)))) (tramp-parse-file filename 'tramp-parse-etc-group-group)))) (defun tramp-parse-etc-group-group () @@ -2746,8 +2746,8 @@ User is always nil." (when (zerop (tramp-call-process nil "reg" nil t nil "query" registry-or-dirname)) (goto-char (point-min)) - (loop while (not (eobp)) collect - (tramp-parse-putty-group registry-or-dirname))))) + (cl-loop while (not (eobp)) collect + (tramp-parse-putty-group registry-or-dirname))))) ;; UNIX case. (tramp-parse-shostkeys-sknownhosts registry-or-dirname (concat "^\\(" tramp-host-regexp "\\)$"))))