From ccca97f2264b64a0474fcc68378ebeb10b72f1e7 Mon Sep 17 00:00:00 2001 From: Stephan Creutz Date: Sat, 30 Jan 2021 13:17:05 +0100 Subject: [PATCH] Replace cl by cl-lib Since Emacs 27 the package cl is deprecated, the replacement is cl-lib, which is available since Emacs 24.3. This patch replaces cl by cl-lib and drops support for Emacs versions less than 24.3. Dropping older Emacsen is required, because cl-lib is a builtin starting from version 24.3 and doesn't need an extra package from ELPA. Testcases for past issues still contain cl. Most of them seem to be broken and need further investigation. This patch is tested with test/run-ert.sh, which outputs: Ran 10 tests, 10 results as expected, 0 unexpected (2021-01-30 13:24:54+0100, 0.672122 sec) 1 expected failures and manually by daily usage for a month now. --- README.md | 2 +- el-get-autoloading.el | 6 +- el-get-build.el | 9 +-- el-get-bundle.el | 6 +- el-get-byte-compile.el | 58 +++++++-------- el-get-check.el | 69 +++++++++--------- el-get-core.el | 84 +++++++++++----------- el-get-custom.el | 3 +- el-get-dependencies.el | 130 +++++++++++++++++----------------- el-get-list-packages.el | 12 ++-- el-get-methods.el | 4 +- el-get-recipes.el | 71 ++++++++++--------- el-get-status.el | 128 ++++++++++++++++----------------- el-get.el | 93 ++++++++++++------------ methods/el-get-elpa.el | 31 ++++---- methods/el-get-emacsmirror.el | 5 +- methods/el-get-emacswiki.el | 5 +- methods/el-get-fossil.el | 9 +-- methods/el-get-git.el | 5 +- methods/el-get-github.el | 9 +-- methods/el-get-http-tar.el | 27 +++---- methods/el-get-http-zip.el | 13 ++-- test/caching-speedtest.el | 6 +- test/el-get-tests.el | 30 ++++---- test/test-setup.el | 3 +- 25 files changed, 417 insertions(+), 401 deletions(-) diff --git a/README.md b/README.md index 0cc0c03e..f8450215 100644 --- a/README.md +++ b/README.md @@ -58,7 +58,7 @@ packages providing some. # Installation El-Get is easy to install. The only requirements to do so successfully are -Emacs (23.4 and above), `git` and a connection to the internet that allows you to `git clone` +Emacs (24.3 and above), `git` and a connection to the internet that allows you to `git clone` repositories. If you do not already have `git` on your system, you can install it through diff --git a/el-get-autoloading.el b/el-get-autoloading.el index 92ae05a3..9a3d4023 100644 --- a/el-get-autoloading.el +++ b/el-get-autoloading.el @@ -12,7 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution -(require 'cl) +(require 'cl-lib) (require 'el-get-core) (require 'el-get-custom) (require 'autoload) @@ -80,8 +80,8 @@ (when (el-get-package-is-installed package) (mapc 'update-directory-autoloads - (remove-if-not #'file-directory-p - (el-get-load-path package))) + (cl-remove-if-not #'file-directory-p + (el-get-load-path package))) (let ((visiting (find-buffer-visiting el-get-autoload-file))) ;; `update-directory-autoloads' leaves file open diff --git a/el-get-build.el b/el-get-build.el index 8328d968..082a1f62 100644 --- a/el-get-build.el +++ b/el-get-build.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-core) (require 'el-get-byte-compile) (require 'el-get-recipes) @@ -65,10 +66,10 @@ Otherwise, use `:build/SYSTEM-TYPE' or `:build'." ;; Verify that each build command is a string or a list of strings (let ((invalid-cmds - (remove-if (lambda (cmd) - (or (stringp cmd) - (el-get-list-of-strings-p cmd))) - flat-build-commands))) + (cl-remove-if (lambda (cmd) + (or (stringp cmd) + (el-get-list-of-strings-p cmd))) + flat-build-commands))) (when invalid-cmds (error "Package %s has invalid build commands: %S" package invalid-cmds))) flat-build-commands)) diff --git a/el-get-bundle.el b/el-get-bundle.el index 40c7ebb2..a825aa8c 100644 --- a/el-get-bundle.el +++ b/el-get-bundle.el @@ -11,7 +11,7 @@ ;;; Code: (require 'el-get) -(eval-when-compile (require 'cl)) +(eval-when-compile (require 'cl-lib)) ;; customization @@ -279,7 +279,7 @@ version is used if `el-get-bundle-byte-compile' is non-nil." (setq form (nthcdr 2 form) require t)) ;; parse keywords (while (keywordp (nth 0 form)) - (case (nth 0 form) + (cl-case (nth 0 form) (:bundle-sync (setq sync (nth 1 form))) (:bundle-async (setq sync (not (nth 1 form)))) (t (setq src (plist-put src (nth 0 form) (nth 1 form))))) @@ -312,7 +312,7 @@ required." `(el-get-bundle ,package ,@args) (let* ((package (or (and (listp package) (nth 1 package)) package)) (name (plist-get (el-get-bundle-parse-name package) :name))) - `(el-get-bundle ,name ,@(list* 'in package args))))) + `(el-get-bundle ,name ,@(cl-list* 'in package args))))) (provide 'el-get-bundle) ;;; el-get-bundle.el ends here diff --git a/el-get-byte-compile.el b/el-get-byte-compile.el index 168df21c..43e5d137 100644 --- a/el-get-byte-compile.el +++ b/el-get-byte-compile.el @@ -12,7 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution -(require 'cl) ; yes I like loop +(require 'cl-lib) ; yes I like loop (require 'bytecomp) (declare-function el-get-build-commands "el-get-build" (package)) @@ -103,28 +103,28 @@ newer, then compilation is skipped." With optional arg RECURSIVE, do so in all subdirectories as well." ;; Process elc files in this dir (let ((elc-files (directory-files dir 'full "\\.elc$"))) - (loop for elc in elc-files - for el = (concat (file-name-sans-extension elc) ".el") - if (and (file-exists-p elc) - (not (file-directory-p elc)) - (not (file-newer-than-file-p elc el))) - do (progn - (message "el-get-byte-compile: Cleaning stale compiled file %s" elc) - (delete-file elc))) + (cl-loop for elc in elc-files + for el = (concat (file-name-sans-extension elc) ".el") + if (and (file-exists-p elc) + (not (file-directory-p elc)) + (not (file-newer-than-file-p elc el))) + do (progn + (message "el-get-byte-compile: Cleaning stale compiled file %s" elc) + (delete-file elc))) ;; Process subdirectories recursively (when recursive - (loop for dir in (directory-files dir 'full) - for localdir = (file-name-nondirectory dir) - if (file-directory-p dir) - unless (member localdir '("." ".." - ;; This list of dirs to ignore courtesy of ack - ;; http://betterthangrep.com/ - "autom4te.cache" "blib" "_build" - ".bzr" ".cdv" "cover_db" "CVS" "_darcs" - "~.dep" "~.dot" ".git" ".hg" "_MTN" - "~.nib" ".pc" "~.plst" "RCS" "SCCS" - "_sgbak" ".svn")) - do (el-get-clean-stale-compiled-files dir recursive))))) + (cl-loop for dir in (directory-files dir 'full) + for localdir = (file-name-nondirectory dir) + if (file-directory-p dir) + unless (member localdir '("." ".." + ;; This list of dirs to ignore courtesy of ack + ;; http://betterthangrep.com/ + "autom4te.cache" "blib" "_build" + ".bzr" ".cdv" "cover_db" "CVS" "_darcs" + "~.dep" "~.dot" ".git" ".hg" "_MTN" + "~.nib" ".pc" "~.plst" "RCS" "SCCS" + "_sgbak" ".svn")) + do (el-get-clean-stale-compiled-files dir recursive))))) (defun el-get-byte-compile-from-stdin () "byte compile files from stdin. @@ -137,8 +137,8 @@ in `:compile-files' will be byte-compiled. Standard input can also contain a `:clean-directory' property, whose value is a directory to be cleared of stale elc files." - (assert noninteractive nil - "`el-get-byte-compile-from-stdin' is to be used only with -batch") + (cl-assert noninteractive nil + "`el-get-byte-compile-from-stdin' is to be used only with -batch") (let* ((input-data (read-minibuffer "")) (files (plist-get input-data :compile-files)) (input-load-path (plist-get input-data :load-path)) @@ -150,14 +150,14 @@ whose value is a directory to be cleared of stale elc files." (unless (or dir-to-clean files) (warn "Did not get a list of files to byte-compile or a directory to clean. The input may have been corrupted.")) (when dir-to-clean - (assert (stringp dir-to-clean) nil - "The value of `:clean-directory' must be a string.") + (cl-assert (stringp dir-to-clean) nil + "The value of `:clean-directory' must be a string.") (message "el-get-byte-compile: Cleaning stale compiled files in %s" dir-to-clean) (el-get-clean-stale-compiled-files dir-to-clean 'recursive)) - (loop for f in files - do (progn - (message "el-get-byte-compile: %s" f) - (el-get-byte-compile-file-or-directory f))))) + (cl-loop for f in files + do (progn + (message "el-get-byte-compile: %s" f) + (el-get-byte-compile-file-or-directory f))))) (defun el-get-byte-compile-process (package buffer working-dir sync files) "return the `el-get-start-process-list' entry to byte compile PACKAGE" diff --git a/el-get-check.el b/el-get-check.el index 16dee38b..87bc20cf 100644 --- a/el-get-check.el +++ b/el-get-check.el @@ -19,6 +19,7 @@ ;;; Code: +(require 'cl-lib) (require 'el-get-recipes) (require 'el-get-build) @@ -68,23 +69,23 @@ Current possibe elements are: <:level> can be any valid warning level, see `warning-levels'. See `el-get-check-suppressed-warnings' for possible values." - (assert noninteractive nil + (cl-assert noninteractive nil "`el-get-check-recipe-batch' should only be used with -batch") (setq vc-handled-backends nil) ; avoid loading VC during batch mode - (loop for arg in command-line-args-left - if (string-match "\\`-Wno-\\(.*\\)" arg) - do (push (intern (match-string 1 arg)) el-get-check-suppressed-warnings) - else if (string-match "\\`-W\\(:[-a-z]*\\)" arg) - do (setq warning-minimum-log-level - (setq warning-minimum-level (intern (match-string 1 arg)))) - else summing - (if (file-directory-p arg) - (reduce #'+ (directory-files arg t "\\.rcp$" t) - :key #'el-get-check-recipe-batch-1 :initial-value 0) - (el-get-check-recipe-batch-1 arg)) - into errors - finally (progn (message "%d warning/error(s) total." errors) - (kill-emacs (if (zerop errors) 0 1))))) + (cl-loop for arg in command-line-args-left + if (string-match "\\`-Wno-\\(.*\\)" arg) + do (push (intern (match-string 1 arg)) el-get-check-suppressed-warnings) + else if (string-match "\\`-W\\(:[-a-z]*\\)" arg) + do (setq warning-minimum-log-level + (setq warning-minimum-level (intern (match-string 1 arg)))) + else summing + (if (file-directory-p arg) + (cl-reduce #'+ (directory-files arg t "\\.rcp$" t) + :key #'el-get-check-recipe-batch-1 :initial-value 0) + (el-get-check-recipe-batch-1 arg)) + into errors + finally (progn (message "%d warning/error(s) total." errors) + (kill-emacs (if (zerop errors) 0 1))))) ;;;###autoload (defun el-get-check-recipe (file-or-buffer) @@ -123,7 +124,7 @@ FILENAME defaults to `buffer-file-name'." level el-get-check-warning-buffer) (when (>= (warning-numeric-level level) (warning-numeric-level warning-minimum-level)) - (incf el-get-check-error-count))) + (cl-incf el-get-check-error-count))) (defun el-get-check-recipe-in-current-buffer (recipe-file-name) (let ((inhibit-read-only t) @@ -153,20 +154,20 @@ FILENAME defaults to `buffer-file-name'." (el-get-check-warning :error "File name should match recipe name.")) ;; Check if userspace property is used. - (loop for key in '(:before :after) - for alt in '(:prepare :post-init) - when (plist-get recipe key) - do (el-get-check-warning :warning - "Property %S is for user. Use %S instead." - key alt)) + (cl-loop for key in '(:before :after) + for alt in '(:prepare :post-init) + when (plist-get recipe key) + do (el-get-check-warning :warning + "Property %S is for user. Use %S instead." + key alt)) ;; Check for misformatted plists - (loop for key in recipe by #'cddr - unless (keywordp key) - do (el-get-check-warning :warning - "Property %S is not a keyword!" - key)) - (destructuring-bind (&key type url autoloads feats builtin - &allow-other-keys) + (cl-loop for key in recipe by #'cddr + unless (keywordp key) + do (el-get-check-warning :warning + "Property %S is not a keyword!" + key)) + (cl-destructuring-bind (&key type url autoloads feats builtin + &allow-other-keys) recipe ;; let-binding `features' causes `provide' to throw error (setq feats (plist-get recipe :features)) @@ -204,17 +205,17 @@ FILENAME defaults to `buffer-file-name'." expand-file-name shell-quote-argument))) (dolist (sys '("" "/darwin" "/berkeley-unix" "/windows-nt")) (let ((unsafe (catch 'unsafe-build - (when (some #'stringp (el-get-build-commands pkg-name 'safe-eval sys)) + (when (cl-some #'stringp (el-get-build-commands pkg-name 'safe-eval sys)) (el-get-check-warning :warning ":build%s should be a *list* of string lists." sys)) nil))) (when unsafe (el-get-check-warning :debug ":build%s is unsafep: %s" sys unsafe))))) ;; Check for required properties. - (loop for key in '(:description :name) - unless (plist-get recipe key) - do (el-get-check-warning :error - "Required property %S is not defined." key)) + (cl-loop for key in '(:description :name) + unless (plist-get recipe key) + do (el-get-check-warning + :error "Required property %S is not defined." key)) (with-current-buffer el-get-check-warning-buffer (insert (format "\n%s: %s error(s) found." recipe-file-name el-get-check-error-count)))) el-get-check-error-count)) diff --git a/el-get-core.el b/el-get-core.el index fe8c7e38..0c69d02a 100644 --- a/el-get-core.el +++ b/el-get-core.el @@ -19,7 +19,7 @@ ;; (require 'dired) -(require 'cl) ; needed for `remove-duplicates' +(require 'cl-lib) (require 'simple) ; needed for `apply-partially' (require 'bytecomp) (require 'autoload) @@ -56,9 +56,9 @@ the original object." "Return a list of all keys in PLIST. Duplicates are removed." - (remove-duplicates - (loop for (k _) on plist by #'cddr - collect k) + (cl-remove-duplicates + (cl-loop for (k _) on plist by #'cddr + collect k) :test #'eq)) (defsubst el-get-keyword-name (keyword) @@ -89,32 +89,32 @@ call for doing the named package action in the given method.") "Returns t if NAME is a known el-get install method backend, nil otherwise." (and (el-get-method name :install) t)) -(defun* el-get-register-method (name &key install update remove - install-hook update-hook remove-hook - compute-checksum guess-website) +(cl-defun el-get-register-method (name &key install update remove + install-hook update-hook remove-hook + compute-checksum guess-website) "Register the method for backend NAME, with given functions" (let (method-def) - (loop for required-arg in '(install update remove) - unless (symbol-value required-arg) - do (error "Missing required argument: :%s" required-arg) - do (setq method-def - (plist-put method-def - (intern (format ":%s" required-arg)) - (symbol-value required-arg)))) - (loop for optional-arg in '(install-hook update-hook remove-hook - compute-checksum guess-website) - if (symbol-value optional-arg) - do (setq method-def - (plist-put method-def - (intern (format ":%s" optional-arg)) - (symbol-value optional-arg)))) + (cl-loop for required-arg in '(install update remove) + unless (symbol-value required-arg) + do (error "Missing required argument: :%s" required-arg) + do (setq method-def + (plist-put method-def + (intern (format ":%s" required-arg)) + (symbol-value required-arg)))) + (cl-loop for optional-arg in '(install-hook update-hook remove-hook + compute-checksum guess-website) + if (symbol-value optional-arg) + do (setq method-def + (plist-put method-def + (intern (format ":%s" optional-arg)) + (symbol-value optional-arg)))) (setq el-get-methods (plist-put el-get-methods name method-def)))) (put 'el-get-register-method 'lisp-indent-function (get 'prog1 'lisp-indent-function)) -(defun* el-get-register-derived-method (name derived-from-name - &rest keys &key &allow-other-keys) +(cl-defun el-get-register-derived-method (name derived-from-name + &rest keys &key &allow-other-keys) "Register the method for backend NAME. Defaults for all optional arguments are taken from @@ -241,11 +241,11 @@ entry." ;; (defun el-get-duplicates (list) "Return duplicates found in list." - (loop with dups and once - for elt in list - if (member elt once) collect elt into dups - else collect elt into once - finally return dups)) + (cl-loop with dups and once + for elt in list + if (member elt once) collect elt into dups + else collect elt into once + finally return dups)) (defun el-get-flatten (arg) "Return a version of ARG as a one-level list @@ -276,8 +276,8 @@ given method." (let* ((method (if (keywordp method-name) method-name (intern (concat ":" (format "%s" method-name))))) (actions (plist-get el-get-methods method))) - (assert actions nil - "Unknown recipe type: %s" method) + (cl-assert actions nil + "Unknown recipe type: %s" method) (plist-get actions action))) (defun el-get-check-init () @@ -327,21 +327,21 @@ fail." ;; (defun el-get-package-files (pdir) "Return a list of files loaded from directory PDIR." - (loop with regexp = (format "^%s" (regexp-quote (file-name-as-directory (file-truename pdir)))) - for (f . nil) in load-history - when (and (stringp f) (string-match-p regexp (file-truename f))) - collect (if (string-match-p "\\.elc?$" f) - (file-name-sans-extension f) - f))) + (cl-loop with regexp = (format "^%s" (regexp-quote (file-name-as-directory (file-truename pdir)))) + for (f . nil) in load-history + when (and (stringp f) (string-match-p regexp (file-truename f))) + collect (if (string-match-p "\\.elc?$" f) + (file-name-sans-extension f) + f))) (defun el-get-package-features (pdir) "Return a list of features provided by files in PDIR." - (loop with regexp = (format "^%s" (regexp-quote (file-name-as-directory (expand-file-name pdir)))) - for (f . l) in load-history - when (and (stringp f) (string-match-p regexp (file-truename f))) - nconc (loop for i in l - when (and (consp i) (eq (car i) 'provide)) - collect (cdr i)))) + (cl-loop with regexp = (format "^%s" (regexp-quote (file-name-as-directory (expand-file-name pdir)))) + for (f . l) in load-history + when (and (stringp f) (string-match-p regexp (file-truename f))) + nconc (cl-loop for i in l + when (and (consp i) (eq (car i) 'provide)) + collect (cdr i)))) ;; diff --git a/el-get-custom.el b/el-get-custom.el index e0f64970..18f8e1b7 100644 --- a/el-get-custom.el +++ b/el-get-custom.el @@ -21,6 +21,7 @@ ;; and its methods. See the methods directory for implementation of them. ;; +(require 'cl-lib) (require 'el-get-core) (declare-function widget-editable-list-match "wid-edit" (widget value)) @@ -515,7 +516,7 @@ this is the name to fetch in that system" ) ;; A sorted list of method names (sort - (reduce + (cl-reduce (lambda (r e) (if (symbolp e) (cons diff --git a/el-get-dependencies.el b/el-get-dependencies.el index e745d18a..986421fb 100644 --- a/el-get-dependencies.el +++ b/el-get-dependencies.el @@ -12,7 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution -(require 'cl) +(require 'cl-lib) (require 'el-get-core) (require 'el-get-recipes) @@ -28,7 +28,7 @@ attention to case differences." string start-pos nil ignore-case))))))) (defun el-get-dependencies (packages) "Return the list of packages to install in order." - (multiple-value-bind (plist all-sorted-p non-sorted) + (cl-multiple-value-bind (plist all-sorted-p non-sorted) (topological-sort (apply 'append (mapcar 'el-get-dependencies-graph (el-get-as-list packages)))) (if all-sorted-p @@ -48,13 +48,13 @@ attention to case differences." (cons 'package pdeps) pdeps))) (append (list (append (list package) alldeps)) - (loop for p in pdeps append (el-get-dependencies-graph p))))) + (cl-loop for p in pdeps append (el-get-dependencies-graph p))))) ;; ;; topological sort, see ;; http://rosettacode.org/wiki/Topological_sort#Common_Lisp ;; -(defun* topological-sort (graph &key (test 'eql)) +(cl-defun topological-sort (graph &key (test 'eql)) "Returns a list of packages to install in order. Graph is an association list whose keys are objects and whose @@ -74,35 +74,35 @@ in the topological ordering (i.e., the first value)." (puthash v (cons 0 '()) entries))))) ;; populate entries initially (dolist (gvertex graph) - (destructuring-bind (vertex &rest dependencies) gvertex + (cl-destructuring-bind (vertex &rest dependencies) gvertex (let ((ventry (funcall entry vertex))) (dolist (dependency dependencies) (let ((dentry (funcall entry dependency))) (unless (funcall test dependency vertex) - (incf (car ventry)) + (cl-incf (car ventry)) (push vertex (cdr dentry)))))))) ;; L is the list of sorted elements, and S the set of vertices ;; with no outstanding dependencies. (let ((L '()) - (S (loop for entry being each hash-value of entries - using (hash-key vertex) - when (zerop (car entry)) collect vertex))) + (S (cl-loop for entry being each hash-value of entries + using (hash-key vertex) + when (zerop (car entry)) collect vertex))) ;; Until there are no vertices with no outstanding dependencies, ;; process vertices from S, adding them to L. - (do* () ((endp S)) + (cl-do* () ((cl-endp S)) (let* ((v (pop S)) (ventry (funcall entry v))) (remhash v entries) (dolist (dependant (cdr ventry) (push v L)) - (when (zerop (decf (car (funcall entry dependant)))) + (when (zerop (cl-decf (car (funcall entry dependant)))) (push dependant S))))) ;; return (1) the list of sorted items, (2) whether all items ;; were sorted, and (3) if there were unsorted vertices, the ;; hash table mapping these vertices to their dependants (let ((all-sorted-p (zerop (hash-table-count entries)))) - (values (nreverse L) - all-sorted-p - (unless all-sorted-p - entries)))))) + (cl-values (nreverse L) + all-sorted-p + (unless all-sorted-p + entries)))))) (defun el-get-auto-dependencies (package &optional interactive) "Return a plist with `:depends' based on the `Package-Requires' @@ -114,36 +114,36 @@ A `:minimum-emacs-version' property may also be present." (error "Tried to get Package-Requires of non-installed package, `%s'!" package)) (eval-and-compile (require 'lisp-mnt)) ; `lm-header' - (loop with deps and min-emacs and sub-pkgs - for pdir in (el-get-load-path package) - do (dolist (file (directory-files pdir t "\\.el\\'" t)) - (if (string-suffix-p "-pkg.el" file) - (let ((def-pkg (el-get-read-from-file file))) - (push (intern (nth 1 def-pkg)) sub-pkgs) - (setq deps (nconc (el-get-unquote (nth 4 def-pkg)) deps))) - (with-temp-buffer - (insert-file-contents file) - (let ((pkg-reqs (lm-header "package-requires"))) - (when pkg-reqs - (push (intern (file-name-base file)) sub-pkgs) - (setq deps (nconc (car (read-from-string pkg-reqs)) deps))))))) - finally do - (setq min-emacs (car (cdr (assq 'emacs deps))) - deps (set-difference (remq 'emacs (delete-dups (mapcar #'car deps))) - sub-pkgs)) - (let ((non-el-get-pkgs (remove-if #'el-get-package-def deps))) - (when non-el-get-pkgs - (error "Found non el-get package(s): %s" non-el-get-pkgs))) - finally return - (if interactive - (let ((props-str - (apply #'concat ":depends " (prin1-to-string deps) "\n" - (when min-emacs - (list ":minimum-emacs-version " (prin1-to-string min-emacs) "\n"))))) - (message "%s" props-str) - (kill-new props-str)) - (nconc (if min-emacs (list :minimum-emacs-version min-emacs)) - (list :depends deps))))) + (cl-loop with deps and min-emacs and sub-pkgs + for pdir in (el-get-load-path package) + do (dolist (file (directory-files pdir t "\\.el\\'" t)) + (if (string-suffix-p "-pkg.el" file) + (let ((def-pkg (el-get-read-from-file file))) + (push (intern (nth 1 def-pkg)) sub-pkgs) + (setq deps (nconc (el-get-unquote (nth 4 def-pkg)) deps))) + (with-temp-buffer + (insert-file-contents file) + (let ((pkg-reqs (lm-header "package-requires"))) + (when pkg-reqs + (push (intern (file-name-base file)) sub-pkgs) + (setq deps (nconc (car (read-from-string pkg-reqs)) deps))))))) + finally do + (setq min-emacs (car (cdr (assq 'emacs deps))) + deps (cl-set-difference (remq 'emacs (delete-dups (mapcar #'car deps))) + sub-pkgs)) + (let ((non-el-get-pkgs (cl-remove-if #'el-get-package-def deps))) + (when non-el-get-pkgs + (error "Found non el-get package(s): %s" non-el-get-pkgs))) + finally return + (if interactive + (let ((props-str + (apply #'concat ":depends " (prin1-to-string deps) "\n" + (when min-emacs + (list ":minimum-emacs-version " (prin1-to-string min-emacs) "\n"))))) + (message "%s" props-str) + (kill-new props-str)) + (nconc (if min-emacs (list :minimum-emacs-version min-emacs)) + (list :depends deps))))) (defun el-get-auto-update-dependencies (package buffer &optional interactive) "Update the dependencies of PACKAGE according to its source headers. @@ -161,25 +161,25 @@ corresponding recipe file." (let* ((new-props (el-get-auto-dependencies package)) (recipe (save-excursion (goto-char (point-min)) (read (current-buffer))))) - (loop with auto-updated = nil - for (prop newval) on new-props by #'cddr - for prop-name = (symbol-name prop) - unless (equal newval (plist-get recipe prop)) - do (save-excursion - (goto-char (point-min)) - (let ((have-prop (search-forward prop-name nil t))) - (if have-prop (let ((opoint (point))) - (forward-sexp) - (delete-region opoint (point))) - (insert prop-name)) - (insert " ") - (prin1 newval (current-buffer)) - (unless (looking-at-p " ; auto updated") - (insert " ; auto updated")) - (unless have-prop (insert "\n")) - (setq auto-updated t))) - finally (when interactive - (message "Dependencies of %s %s updated." package - (if auto-updated "have been" "didn't need to be"))))))) + (cl-loop with auto-updated = nil + for (prop newval) on new-props by #'cddr + for prop-name = (symbol-name prop) + unless (equal newval (plist-get recipe prop)) + do (save-excursion + (goto-char (point-min)) + (let ((have-prop (search-forward prop-name nil t))) + (if have-prop (let ((opoint (point))) + (forward-sexp) + (delete-region opoint (point))) + (insert prop-name)) + (insert " ") + (prin1 newval (current-buffer)) + (unless (looking-at-p " ; auto updated") + (insert " ; auto updated")) + (unless have-prop (insert "\n")) + (setq auto-updated t))) + finally (when interactive + (message "Dependencies of %s %s updated." package + (if auto-updated "have been" "didn't need to be"))))))) (provide 'el-get-dependencies) diff --git a/el-get-list-packages.el b/el-get-list-packages.el index 8b20a6d6..76f7edee 100644 --- a/el-get-list-packages.el +++ b/el-get-list-packages.el @@ -17,7 +17,7 @@ ;; Description of packages. (Code based on `describe-function'). ;; (require 'el-get-core) -(require 'cl) +(require 'cl-lib) (declare-function el-get-install "el-get" (package)) (declare-function el-get-remove "el-get" (package)) @@ -134,10 +134,10 @@ matching REGEX with TYPE and ARGS as parameter." (if (listp depends) (progn (princ "Dependencies: ") - (loop for i in depends - do (el-get-describe-princ-button - (format "`%s'" i) "`\\([^`']+\\)" - 'el-get-help-describe-package i))) + (cl-loop for i in depends + do (el-get-describe-princ-button + (format "`%s'" i) "`\\([^`']+\\)" + 'el-get-help-describe-package i))) (princ "Dependency: ") (el-get-describe-princ-button (format "`%s'" depends) "`\\([^`']+\\)" @@ -361,7 +361,7 @@ in el-get package menu." 'font-lock-face face))) (when desc (indent-to (cdr (assoc "Description" el-get-package-list-column-alist)) 1) - (let ((eol (position ?\n desc))) + (let ((eol (cl-position ?\n desc))) (when eol (setq desc (substring desc 0 eol)))) (insert (propertize desc 'font-lock-face face) "\n")))) diff --git a/el-get-methods.el b/el-get-methods.el index 658989e0..769bf873 100644 --- a/el-get-methods.el +++ b/el-get-methods.el @@ -11,6 +11,8 @@ ;; ;; Install ;; Please see the README.md file from the same distribution + +(require 'cl-lib) (require 'el-get-core) (unless (version< emacs-version "24.4") (require 'subr-x)) @@ -42,7 +44,7 @@ following are true: - PACKAGE definition has a non-empty :checksum" (unless el-get-allow-insecure - (assert (stringp url) nil "URL is nil, can't decide if it's safe to install package '%s'" package) + (cl-assert (stringp url) nil "URL is nil, can't decide if it's safe to install package '%s'" package) (let* ((checksum (plist-get (el-get-package-def package) :checksum)) (checksum-empty (or (not (stringp checksum)) (if (fboundp 'string-blank-p) diff --git a/el-get-recipes.el b/el-get-recipes.el index 5abafef2..e75a2b14 100644 --- a/el-get-recipes.el +++ b/el-get-recipes.el @@ -23,6 +23,7 @@ ;;; Code: +(require 'cl-lib) (require 'el-get-core) (require 'el-get-custom) (require 'el-get-byte-compile) @@ -85,9 +86,9 @@ compiled version." "Return the elements of `el-get-recipe-path' that actually exist. Used to avoid errors when exploring the path for recipes" - (reduce (lambda (dir result) - (if (file-directory-p dir) (cons dir result) result)) - el-get-recipe-path :from-end t :initial-value nil)) + (cl-reduce (lambda (dir result) + (if (file-directory-p dir) (cons dir result) result)) + el-get-recipe-path :from-end t :initial-value nil)) ;; recipe files are elisp data, you can't byte-compile or eval them on their ;; own, but having elisp indenting and colors make sense @@ -105,8 +106,8 @@ Used to avoid errors when exploring the path for recipes" (insert "(") ;; Standard Emacs pretty print functions don't put newlines after ;; prop val pairs of plists, so we have to do it ourselves. - (loop for (prop val) on source by #'cddr - do (insert (format "%S %S\n" prop val))) + (cl-loop for (prop val) on source by #'cddr + do (insert (format "%S %S\n" prop val))) (delete-char -1) ; delete last \n (insert ")\n") (goto-char point) @@ -125,11 +126,11 @@ Used to avoid errors when exploring the path for recipes" "Return the name of the file that contains the recipe for PACKAGE, if any." (let ((package-el (concat (el-get-as-string package) ".el")) (package-rcp (concat (el-get-as-string package) ".rcp"))) - (loop for dir in el-get-recipe-path - for recipe-el = (expand-file-name package-el dir) - for recipe-rcp = (expand-file-name package-rcp dir) - if (file-exists-p recipe-el) return recipe-el - if (file-exists-p recipe-rcp) return recipe-rcp))) + (cl-loop for dir in el-get-recipe-path + for recipe-el = (expand-file-name package-el dir) + for recipe-rcp = (expand-file-name package-rcp dir) + if (file-exists-p recipe-el) return recipe-el + if (file-exists-p recipe-rcp) return recipe-rcp))) (defun el-get-read-recipe (package) "Return the source definition for PACKAGE, from the recipes." @@ -142,9 +143,9 @@ Used to avoid errors when exploring the path for recipes" "Return the list of all file based recipe names. The result may have duplicates." - (loop for dir in (el-get-recipe-dirs) - nconc (mapcar #'file-name-base - (directory-files dir nil "^[^.].*\.\\(rcp\\|el\\)$")))) + (cl-loop for dir in (el-get-recipe-dirs) + nconc (mapcar #'file-name-base + (directory-files dir nil "^[^.].*\.\\(rcp\\|el\\)$")))) (defun el-get-read-all-recipe-files () "Return the list of all file based recipes, formated like `el-get-sources'. @@ -153,9 +154,9 @@ Only consider any given recipe only once even if present in multiple dirs from `el-get-recipe-path'. The first recipe found is the one considered." (let (packages) - (loop + (cl-loop for dir in (el-get-recipe-dirs) - nconc (loop + nconc (cl-loop for recipe in (directory-files dir nil "^[^.].*\.\\(rcp\\|el\\)$") for filename = (concat (file-name-as-directory dir) recipe) for pname = (file-name-sans-extension @@ -190,17 +191,17 @@ If R2 has a `:type' it completely replaces R1, otherwise, R1 fields are the default value and R2 may override them." (if (plist-get r2 :type) r2 - (loop with merged - for (prop val) on (append r2 r1) by 'cddr - unless (plist-member merged prop) - nconc (list prop val) into merged - finally return merged))) + (cl-loop with merged + for (prop val) on (append r2 r1) by 'cddr + unless (plist-member merged prop) + nconc (list prop val) into merged + finally return merged))) (defun el-get-package-def (package) "Return a single `el-get-sources' entry for PACKAGE." - (let ((source (loop for src in el-get-sources - when (string= package (el-get-source-name src)) - return src))) + (let ((source (cl-loop for src in el-get-sources + when (string= package (el-get-source-name src)) + return src))) (cond ((or (null source) (symbolp source)) ;; not in `el-get-sources', or only mentioned by name @@ -239,15 +240,15 @@ Only consider packages whose status is `member' of STATUSES, which defaults to installed, required and removed. Example: (el-get-package-types-alist \"installed\" 'http 'cvs)" - (loop for src in (apply 'el-get-list-package-names-with-status - (cond ((stringp statuses) (list statuses)) - ((null statuses) '("installed" "required" - "removed")) - (t statuses))) - for name = (el-get-as-symbol src) - for type = (el-get-package-type name) - when (or (null types) (memq 'all types) (memq type types)) - collect (cons name type))) + (cl-loop for src in (apply 'el-get-list-package-names-with-status + (cond ((stringp statuses) (list statuses)) + ((null statuses) '("installed" "required" + "removed")) + (t statuses))) + for name = (el-get-as-symbol src) + for type = (el-get-package-type name) + when (or (null types) (memq 'all types) (memq type types)) + collect (cons name type))) (defun el-get-package-required-emacs-version (package-or-source) (let* ((def (if (or (symbolp package-or-source) (stringp package-or-source)) @@ -293,7 +294,7 @@ of numbers, which will be returned unmodified." (list version)) ;; List of numbers ((and (listp version) - (null (remove-if 'numberp version))) + (null (cl-remove-if 'numberp version))) version) (t (error "Unrecognized version specification: %S" version)))) @@ -320,8 +321,8 @@ Use this to modify environment variable such as $PATH or $PYTHONPATH." "Return \"HEAD:PATHS\" omitting duplicates in it." (let ((pplist (split-string (or paths "") path-separator 'omit-nulls))) (mapconcat 'identity - (remove-duplicates (cons head pplist) - :test #'string= :from-end t) + (cl-remove-duplicates (cons head pplist) + :test #'string= :from-end t) path-separator))) (provide 'el-get-recipes) diff --git a/el-get-status.el b/el-get-status.el index c4de5970..b0a254b4 100644 --- a/el-get-status.el +++ b/el-get-status.el @@ -19,7 +19,7 @@ ;; miserably. ;; -(require 'cl) +(require 'cl-lib) (require 'pp) (require 'el-get-core) @@ -76,8 +76,8 @@ (lambda (p1 p2) (string< (el-get-as-string (car p1)) (el-get-as-string (car p2))))))) - (assert (listp recipe) nil - "Recipe must be a list") + (cl-assert (listp recipe) nil + "Recipe must be a list") (with-temp-file el-get-status-file (insert (el-get-print-to-string new-package-status-alist 'pretty))) ;; Update cache @@ -105,18 +105,18 @@ (with-temp-file (format "%s.old" el-get-status-file) (insert (el-get-print-to-string old-status-list))) ;; now convert to the new format, fetching recipes as we go - (loop for (p s) on old-status-list by 'cddr - for psym = (el-get-package-symbol p) - when psym - collect - (cons psym - (list 'status s - 'recipe (when (string= s "installed") - (condition-case nil - (el-get-package-def psym) - ;; If the recipe is not available any more, - ;; just provide a placeholder no-op recipe. - (error `(:name ,psym :type builtin)))))))) + (cl-loop for (p s) on old-status-list by 'cddr + for psym = (el-get-package-symbol p) + when psym + collect + (cons psym + (list 'status s + 'recipe (when (string= s "installed") + (condition-case nil + (el-get-package-def psym) + ;; If the recipe is not available any more, + ;; just provide a placeholder no-op recipe. + (error `(:name ,psym :type builtin)))))))) (defun el-get-clear-status-cache () "Clear in-memory cache for status file." @@ -150,23 +150,23 @@ ;; ;; a package with status "installed" and a missing directory is ;; automatically reset to "required" so that a proper install happens. - (loop for (p . prop) in p-s - if (and (string= (plist-get prop 'status) "installed") - (not (file-directory-p (el-get-package-directory p)))) - collect (cons p (plist-put prop 'status "required")) - else - collect (cons p prop)))) + (cl-loop for (p . prop) in p-s + if (and (string= (plist-get prop 'status) "installed") + (not (file-directory-p (el-get-package-directory p)))) + collect (cons p (plist-put prop 'status "required")) + else + collect (cons p prop)))) (defun el-get-package-status-alist () "return an alist of (PACKAGE . STATUS)" - (loop for (p . prop) in (el-get-read-status-file) - collect (cons p (plist-get prop 'status)))) + (cl-loop for (p . prop) in (el-get-read-status-file) + collect (cons p (plist-get prop 'status)))) (defun el-get-package-status-recipes () "return the list of recipes stored in the status file" - (loop for (p . prop) in (el-get-read-status-file) - when (string= (plist-get prop 'status) "installed") - collect (plist-get prop 'recipe))) + (cl-loop for (p . prop) in (el-get-read-status-file) + when (string= (plist-get prop 'status) "installed") + collect (plist-get prop 'recipe))) (defun el-get-read-package-status (package) "return current status for PACKAGE" @@ -182,10 +182,10 @@ (defun el-get-filter-package-alist-with-status (package-status-alist &rest statuses) "Return package names that are currently in given status" - (loop for (p . prop) in package-status-alist - for s = (plist-get prop 'status) - when (member s statuses) - collect (el-get-as-string p))) + (cl-loop for (p . prop) in package-status-alist + for s = (plist-get prop 'status) + when (member s statuses) + collect (el-get-as-string p))) (defun el-get-list-package-names-with-status (&rest statuses) "Return package names that are currently in given status" @@ -204,7 +204,7 @@ (defun el-get-count-packages-with-status (packages &rest statuses) "Return how many packages are currently in given status in PACKAGES" - (length (intersection + (length (cl-intersection (mapcar #'el-get-as-symbol (apply #'el-get-list-package-names-with-status statuses)) (mapcar #'el-get-as-symbol packages)))) @@ -212,16 +212,16 @@ "Return installed or required packages that are not in given package list" (let ((packages ;; &rest could contain both symbols and lists - (loop for p in packages - when (listp p) append (mapcar 'el-get-as-symbol p) - else collect (el-get-as-symbol p)))) + (cl-loop for p in packages + when (listp p) append (mapcar 'el-get-as-symbol p) + else collect (el-get-as-symbol p)))) (when packages - (loop for (p . prop) in (el-get-read-status-file) - for s = (plist-get prop 'status) - for x = (el-get-package-symbol p) - unless (member x packages) - unless (equal s "removed") - collect (list x s))))) + (cl-loop for (p . prop) in (el-get-read-status-file) + for s = (plist-get prop 'status) + for x = (el-get-package-symbol p) + unless (member x packages) + unless (equal s "removed") + collect (list x s))))) (defmacro el-get-with-status-sources (_ &rest body) "Evaluate BODY with `el-get-sources' according to the status file." @@ -266,29 +266,29 @@ that recipe in the el-get status file.") Partition the properties of NEWPROPS whose value is different from SOURCE into 3 sublists, (INIT UPDATE REINSTALL), according to the operation required." - (loop with init and update and reinstall - with type = (let ((old-type (el-get-package-method source)) - (new-type (el-get-package-method newprops))) - (if (eq old-type new-type) old-type nil)) - for (k v) on newprops by 'cddr - if (equal v (plist-get source k)) do (ignore) ; Ignore non-changes. - else if - (or (memq k el-get-status-init-whitelist) - (if (eq k :builtin) ; `:builtin' safe if not crossing versions. - (eq (version<= emacs-version (el-get-as-string v)) - (version<= emacs-version (el-get-as-string - (plist-get source k)))))) - do (setq init (plist-put init k v)) - else if (or (memq k el-get-status-update-whitelist) - ;; All `:build/*' props are update safe, like `:build'. - (string-prefix-p ":build/" (symbol-name k)) - (if (eq k :url) ; `:http*' methods can handle `:url' changes. - (memq type '(http http-tar http-zip - github-tar github-zip - builtin)))) - do (setq update (plist-put update k v)) - else do (setq reinstall (plist-put reinstall k v)) - finally return (list init update reinstall))) + (cl-loop with init and update and reinstall + with type = (let ((old-type (el-get-package-method source)) + (new-type (el-get-package-method newprops))) + (if (eq old-type new-type) old-type nil)) + for (k v) on newprops by 'cddr + if (equal v (plist-get source k)) do (ignore) ; Ignore non-changes. + else if + (or (memq k el-get-status-init-whitelist) + (if (eq k :builtin) ; `:builtin' safe if not crossing versions. + (eq (version<= emacs-version (el-get-as-string v)) + (version<= emacs-version (el-get-as-string + (plist-get source k)))))) + do (setq init (plist-put init k v)) + else if (or (memq k el-get-status-update-whitelist) + ;; All `:build/*' props are update safe, like `:build'. + (string-prefix-p ":build/" (symbol-name k)) + (if (eq k :url) ; `:http*' methods can handle `:url' changes. + (memq type '(http http-tar http-zip + github-tar github-zip + builtin)))) + do (setq update (plist-put update k v)) + else do (setq reinstall (plist-put reinstall k v)) + finally return (list init update reinstall))) (defun el-get-diagnosis-properties (old-source new-source) "Diagnosis difference between OLD-SOURCE and NEW-SOURCE. @@ -359,7 +359,7 @@ t', this error is suppressed (but nothing is updated). (el-get-read-cached-recipe package source))) (unless (el-get-package-is-installed package) (error "Package %s is not installed. Cannot update recipe." package)) - (destructuring-bind (required-ops added removed) + (cl-destructuring-bind (required-ops added removed) (el-get-diagnosis-properties cached-recipe source) (if (and required-ops (not (memq operation required-ops))) ;; Emit a verbose message if `noerror' is t (but still quit diff --git a/el-get.el b/el-get.el index f8d231a2..1cd4dc00 100644 --- a/el-get.el +++ b/el-get.el @@ -179,6 +179,7 @@ ;;; Code: +(require 'cl-lib) (require 'el-get-core) ; core facilities used everywhere (require 'el-get-custom) ; user tweaks and `el-get-sources' (require 'el-get-methods) ; support for `el-get-methods', backends @@ -246,7 +247,7 @@ Completions are offered from all known package names, after removing any packages in FILTERED." (let ((packages (el-get-read-all-recipe-names))) (completing-read (format "%s package: " action) - (set-difference packages filtered :test 'string=) nil t))) + (cl-set-difference packages filtered :test 'string=) nil t))) (defun el-get-read-recipe-name (action) "Ask user for a recipe name, with completion from the list of known recipe files. @@ -311,7 +312,7 @@ which defaults to the first element in `el-get-recipe-path'." ;; Convert it to a quoted call to that function (prog1 `(,form) (if (and (listp form) - (equal (subseq form 0 2) '(lambda ()))) + (equal (cl-subseq form 0 2) '(lambda ()))) ;; It's a zero-arg function, so it can be trivially ;; rewritten as a progn. Inform the user of such. (warn "The :%s form for package %s uses the old-style lambda form instead of a lisp form. The leading \"(lambda ()\" should be replaced with \"(progn\"." @@ -326,7 +327,7 @@ which defaults to the first element in `el-get-recipe-path'." (t (error "Unknown :%s form for package %s: `%S'" fname package form))))) (when form - (assert (listp form)) + (cl-assert (listp form)) (el-get-verbose-message "el-get: Evaluating :%s form for package %s" fname package) ;; don't forget to make some variables available @@ -352,7 +353,7 @@ which defaults to the first element in `el-get-recipe-path'." (el-get-verbose-message "el-get-init: %s" package) (let* ((init-deps (el-get-dependencies (el-get-as-symbol package)))) (el-get-verbose-message "el-get-init: " init-deps) - (loop for p in init-deps do (el-get-do-init p) collect p))) + (cl-loop for p in init-deps do (el-get-do-init p) collect p))) (defun el-get-do-init (package &optional package-status-alist) "Make the named PACKAGE available for use. @@ -593,7 +594,7 @@ PACKAGE may be either a string or the corresponding symbol." (package-features (el-get-package-features pdir)) (package-files (el-get-package-files pdir)) (other-features - (remove-if (lambda (x) (memq x package-features)) all-features))) + (cl-remove-if (lambda (x) (memq x package-features)) all-features))) (unwind-protect (progn ;; We cannot let-bind `features' here, becauses the changes @@ -601,30 +602,30 @@ PACKAGE may be either a string or the corresponding symbol." (setq features other-features) ;; Reload all loaded files in package dir if they still ;; exist. - (loop for file in package-files - ;; We convert errors to warnings here, because some - ;; files don't like being loaded more than once in a - ;; session. Example: "cedet-remove-builtin.el" from - ;; CEDET. - do (condition-case e - (load file 'noerror) - (error (warn "Error while reloading file %s in package %s: %S\n\n This package may require a restart of emacs to complete the update process." - file package (cdr e))))) + (cl-loop for file in package-files + ;; We convert errors to warnings here, because some + ;; files don't like being loaded more than once in a + ;; session. Example: "cedet-remove-builtin.el" from + ;; CEDET. + do (condition-case e + (load file 'noerror) + (error (warn "Error while reloading file %s in package %s: %S\n\n This package may require a restart of emacs to complete the update process." + file package (cdr e))))) ;; Redo package initialization (el-get-init package) ;; Reload all features provided by the package. This ensures ;; that autoloaded packages (which normally don't load ;; anything until one of their entry points is called) are ;; forced to reload immediately if they were already loaded. - (loop for f in package-features - do (require f nil 'noerror))) + (cl-loop for f in package-features + do (require f nil 'noerror))) ;; We have to add all the removed features back in no matter ;; what, or else we would be lying about what has been loaded. ;; This covers the corner case where an updated package no ;; longer provides a certain feature. Technically that feature ;; is still provided, so not adding it back would be wrong. (let ((missing-features - (remove-if (lambda (x) (memq x features)) package-features))) + (cl-remove-if (lambda (x) (memq x features)) package-features))) (when missing-features (warn "Adding %S back onto features, because the reloaded package did not provide them." missing-features) @@ -667,15 +668,15 @@ different install methods." (defun el-get-do-update (package) "Update " (el-get-error-unless-package-p package) - (assert (el-get-package-is-installed package) nil + (cl-assert (el-get-package-is-installed package) nil "Package %s cannot be updated because it is not installed." package) (let* ((package (el-get-as-symbol package)) (source (el-get-package-def package)) (method (el-get-package-method source)) (update (el-get-method method :update)) (url (plist-get source :url))) - (assert (null (remove-if 'el-get-package-is-installed - (el-get-dependencies package))) + (cl-assert (null (cl-remove-if 'el-get-package-is-installed + (el-get-dependencies package))) nil "Dependencies of package %s should already be installed before updating" package) @@ -700,8 +701,8 @@ itself.") (if (el-get-update-requires-reinstall package) (el-get-reinstall package) (let* ((package (el-get-as-symbol package)) - (new-dependencies (remove-if 'el-get-package-is-installed - (el-get-dependencies package))) + (new-dependencies (cl-remove-if 'el-get-package-is-installed + (el-get-dependencies package))) (source (el-get-package-def package))) (if (plist-get source :checksum) (error "el-get: remove checksum from package %s to update it." package) @@ -852,7 +853,7 @@ explicitly declared in the user-init-file (.emacs)." (let* ((packages-to-keep (el-get-dependencies (mapcar 'el-get-as-symbol (add-to-list 'packages 'el-get)))) - (packages-to-remove (set-difference + (packages-to-remove (cl-set-difference (mapcar 'el-get-as-symbol (el-get-list-package-names-with-status "installed")) packages-to-keep))) @@ -886,10 +887,10 @@ explicitly declared in the user-init-file (.emacs)." entry which is not a symbol and is not already a known recipe." (interactive "Dsave recipes in directory: ") (let* ((all (el-get-read-all-recipe-names)) - (new (loop for r in el-get-sources - when (and (not (symbolp r)) - (not (member (el-get-source-name r) all))) - collect r))) + (new (cl-loop for r in el-get-sources + when (and (not (symbolp r)) + (not (member (el-get-source-name r) all))) + collect r))) (dolist (r new) (message "el-get: preparing recipe file for %s" (el-get-source-name r)) (el-get-write-recipe r dir))) @@ -935,36 +936,36 @@ considered \"required\"." (required (el-get-filter-package-alist-with-status p-s-alist "required")) (installed (el-get-filter-package-alist-with-status p-s-alist "installed")) (to-init (if packages - (loop for p in packages - when (member (el-get-as-string p) installed) - collect p) + (cl-loop for p in packages + when (member (el-get-as-string p) installed) + collect p) (mapcar 'el-get-as-symbol installed))) (init-deps (el-get-dependencies to-init)) - (req-inits (loop for p in init-deps - unless (member (el-get-as-string p) installed) - collect p)) + (req-inits (cl-loop for p in init-deps + unless (member (el-get-as-string p) installed) + collect p)) (to-install (if packages - (loop for p in packages - unless (member p init-deps) - collect p) + (cl-loop for p in packages + unless (member p init-deps) + collect p) (mapcar 'el-get-as-symbol required))) (install-deps (el-get-dependencies to-install)) done) (when req-inits ; we can't init a pkg unless it's installed! (setq install-deps (append req-inits install-deps)) - (setq init-deps (set-difference init-deps req-inits))) + (setq init-deps (cl-set-difference init-deps req-inits))) (el-get-verbose-message "el-get-init-and-install: install %S" install-deps) (el-get-verbose-message "el-get-init-and-install: init %S" init-deps) - (loop for p in install-deps - when (el-get-with-errors-as-warnings (format "while installing %s: " p) - (el-get-do-install p)) - collect p into done) - (loop for p in init-deps - when (el-get-with-errors-as-warnings (format "while initializing %s: " p) - (el-get-do-init p)) - collect p into done) + (cl-loop for p in install-deps + when (el-get-with-errors-as-warnings (format "while installing %s: " p) + (el-get-do-install p)) + collect p into done) + (cl-loop for p in init-deps + when (el-get-with-errors-as-warnings (format "while initializing %s: " p) + (el-get-do-init p)) + collect p into done) done)) ;;;###autoload @@ -998,7 +999,7 @@ already installed packages is considered." (let* ((packages ;; (el-get 'sync 'a 'b my-package-list) - (loop for p in packages when (listp p) append p else collect p)) + (cl-loop for p in packages when (listp p) append p else collect p)) (el-get-default-process-sync sync)) ;; load autoloads before package init so :after blocks can use the diff --git a/methods/el-get-elpa.el b/methods/el-get-elpa.el index fb0e8774..dcd87257 100644 --- a/methods/el-get-elpa.el +++ b/methods/el-get-elpa.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-core) (require 'el-get-recipes) (require 'package nil t) @@ -92,15 +93,15 @@ PACKAGE isn't currently installed by ELPA." (pregex (concat "\\`" (regexp-quote pname) "-")) (version-offset (+ (length pname) 1))) (catch 'dir - (loop for pkg-base-dir in (cons package-user-dir - (when (boundp 'package-directory-list) - package-directory-list)) - when (file-directory-p pkg-base-dir) - do - (loop for pkg-dir in (directory-files pkg-base-dir nil pregex) - if (ignore-errors - (version-to-list (substring pkg-dir version-offset))) - do (throw 'dir (expand-file-name pkg-dir pkg-base-dir)))) + (cl-loop for pkg-base-dir in (cons package-user-dir + (when (boundp 'package-directory-list) + package-directory-list)) + when (file-directory-p pkg-base-dir) + do + (cl-loop for pkg-dir in (directory-files pkg-base-dir nil pregex) + if (ignore-errors + (version-to-list (substring pkg-dir version-offset))) + do (throw 'dir (expand-file-name pkg-dir pkg-base-dir)))) nil))) (defun el-get-elpa-package-repo (package) @@ -206,8 +207,8 @@ the recipe, then return nil." (defun el-get-elpa-update-available-p (package) "Returns t if PACKAGE has an update available in ELPA." - (assert (el-get-package-is-installed package) nil - (format "Cannot update non-installed ELPA package %s" package)) + (cl-assert (el-get-package-is-installed package) nil + (format "Cannot update non-installed ELPA package %s" package)) (let* ((installed-version (package-desc-version (car (el-get-elpa-descs (assq package package-alist))))) (available-packages @@ -215,10 +216,10 @@ the recipe, then return nil." ;; Emacs 24.4 keeps lists of available packages. `package-alist' ;; is sorted by version, but `package-archive-contents' is not, so ;; we should loop through it. - (some (lambda (pkg) - (version-list-< installed-version - (package-desc-version pkg))) - available-packages))) + (cl-some (lambda (pkg) + (version-list-< installed-version + (package-desc-version pkg))) + available-packages))) (defvar el-get-elpa-do-refresh t "Whether to call `package-refresh-contents' during `el-get-elpa-update'. diff --git a/methods/el-get-emacsmirror.el b/methods/el-get-emacsmirror.el index 85751a7a..02e3752e 100644 --- a/methods/el-get-emacsmirror.el +++ b/methods/el-get-emacsmirror.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-core) (require 'el-get-recipes) (require 'el-get-git) @@ -19,8 +20,8 @@ (defun el-get-emacsmirror-get-github-source (package) "Return a github-type source equivalent to emacsmirror PACKAGE." - (assert (equal (el-get-package-type package) 'emacsmirror) nil - "Need an emacsmirror package") + (cl-assert (equal (el-get-package-type package) 'emacsmirror) nil + "Need an emacsmirror package") (append `(:type github :pkgname ,(format "emacsmirror/%s" package)) (el-get-package-def package))) diff --git a/methods/el-get-emacswiki.el b/methods/el-get-emacswiki.el index 7f0cc0a1..06a59eab 100644 --- a/methods/el-get-emacswiki.el +++ b/methods/el-get-emacswiki.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-recipes) (require 'el-get-notify) (require 'el-get-http) @@ -73,7 +74,7 @@ filename.el ;;; filename.el --- description" (buffer-substring (point) (line-end-position)))) (re-search-forward "^$" nil 'move) (forward-char) - (loop + (cl-loop with wiki-regexp = (concat "^\\([^[:space:]]+\\.el\\)" ; filename "\\(?:" ; optional separators @@ -98,7 +99,7 @@ into a local recipe file set" el-get-recipe-path-emacswiki)) (coding-system-for-write 'utf-8)) (unless (file-directory-p target-dir) (make-directory target-dir 'recursive)) - (loop + (cl-loop with wiki-list = (el-get-emacswiki-retrieve-package-list) with progress = (make-progress-reporter "Generating Emacswiki recipes" 0 (length wiki-list)) diff --git a/methods/el-get-fossil.el b/methods/el-get-fossil.el index bfc6d9d6..b0e00181 100755 --- a/methods/el-get-fossil.el +++ b/methods/el-get-fossil.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-core) (require 'el-get-custom) @@ -131,10 +132,10 @@ checkout of the repository using this command." ;; Fix multi-line comment output to be a single string (replace-regexp-in-string "\n +" " " (buffer-string)) "\n" t))) - (assert (= error 0) nil - "Package %s is not a fossil package" package) - (loop for x in fossil-info - collect (split-string x ": +"))))) + (cl-assert (= error 0) nil + "Package %s is not a fossil package" package) + (cl-loop for x in fossil-info + collect (split-string x ": +"))))) (defun el-get-fossil-compute-checksum (package) "Return the hash of the checked-out revision of PACKAGE." diff --git a/methods/el-get-git.el b/methods/el-get-git.el index 7c6080fd..99f63805 100644 --- a/methods/el-get-git.el +++ b/methods/el-get-git.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-core) (require 'el-get-recipes) @@ -204,8 +205,8 @@ not return 'smart' headers despite supporting shallow clones" ;; type. Instead, we check for the existence of a ".git" directory ;; in the package directory. A better approach might be to call ;; "git status" and check that it returns success. - (assert (file-directory-p ".git") nil - "Package %s is not a git package" package) + (cl-assert (file-directory-p ".git") nil + "Package %s is not a git package" package) (with-temp-buffer (call-process (el-get-executable-find "git") nil '(t t) nil "log" "--pretty=format:%H" "-n1") diff --git a/methods/el-get-github.el b/methods/el-get-github.el index 042d0628..f860bc8a 100644 --- a/methods/el-get-github.el +++ b/methods/el-get-github.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-core) (require 'el-get-git) @@ -51,10 +52,10 @@ FROM is a literal string, not a regexp." (error ":pkgname \"username/reponame\" is mandatory for github recipe '%s" package))) (user-and-repo (split-string user-slash-repo "/" 'omit-nulls))) - (assert (= (length user-and-repo) 2) nil - "Github pkgname %s must be of the form username/reponame" - user-slash-repo) - (cons (first user-and-repo) (second user-and-repo)))) + (cl-assert (= (length user-and-repo) 2) nil + "Github pkgname %s must be of the form username/reponame" + user-slash-repo) + (cons (cl-first user-and-repo) (cl-second user-and-repo)))) (defun el-get-github-url-private (url-type username reponame) "Return the url of a particular github project. diff --git a/methods/el-get-http-tar.el b/methods/el-get-http-tar.el index c8314078..855ce03a 100644 --- a/methods/el-get-http-tar.el +++ b/methods/el-get-http-tar.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-http) (defun el-get-http-unpack-cleanup-extract-hook (package) @@ -26,13 +27,13 @@ ;; if there's only one directory, move its content up and get rid of it (when (and (not (cdr files)) (file-directory-p (expand-file-name dir pdir))) - (loop for fname in (directory-files - (expand-file-name dir pdir) nil "[^.]$") - for fullname = (expand-file-name fname (expand-file-name dir pdir)) - for newname = (expand-file-name fname pdir) - do (progn - (el-get-verbose-message "mv %S %S" fullname newname) - (rename-file fullname newname))) + (cl-loop for fname in (directory-files + (expand-file-name dir pdir) nil "[^.]$") + for fullname = (expand-file-name fname (expand-file-name dir pdir)) + for newname = (expand-file-name fname pdir) + do (progn + (el-get-verbose-message "mv %S %S" fullname newname) + (rename-file fullname newname))) (el-get-verbose-message "delete-directory: %s" (expand-file-name dir pdir)) (delete-directory (expand-file-name dir pdir))))) @@ -50,12 +51,12 @@ ;; Remove all files from previous install before ;; extracting the tar file. (let ((files-to-delete (remove ,tarfile (directory-files ,pdir nil "[^.]$")))) - (loop for fname in files-to-delete - for fullpath = (expand-file-name fname ,pdir) - do (el-get-verbose-message "el-get-http-tar: Deleting old file %S" fname) - do (if (file-directory-p fullpath) - (delete-directory fullpath 'recursive) - (delete-file fullpath)))) + (cl-loop for fname in files-to-delete + for fullpath = (expand-file-name fname ,pdir) + do (el-get-verbose-message "el-get-http-tar: Deleting old file %S" fname) + do (if (file-directory-p fullpath) + (delete-directory fullpath 'recursive) + (delete-file fullpath)))) ;; verify checksum before operating on untrusted data (el-get-verify-checksum package) ;; tar xzf `basename url` diff --git a/methods/el-get-http-zip.el b/methods/el-get-http-zip.el index d556077c..d0b937db 100644 --- a/methods/el-get-http-zip.el +++ b/methods/el-get-http-zip.el @@ -12,6 +12,7 @@ ;; Install ;; Please see the README.md file from the same distribution +(require 'cl-lib) (require 'el-get-http) (require 'el-get-http-tar) @@ -29,12 +30,12 @@ ;; Remove all files from previous install before ;; extracting the tar file. (let ((files-to-delete (remove ,zipfile (directory-files ,pdir nil "[^.]$")))) - (loop for fname in files-to-delete - for fullpath = (expand-file-name fname ,pdir) - do (el-get-verbose-message "el-get-http-tar: Deleting old file %S" fname) - do (if (file-directory-p fullpath) - (delete-directory fullpath 'recursive) - (delete-file fullpath)))) + (cl-loop for fname in files-to-delete + for fullpath = (expand-file-name fname ,pdir) + do (el-get-verbose-message "el-get-http-tar: Deleting old file %S" fname) + do (if (file-directory-p fullpath) + (delete-directory fullpath 'recursive) + (delete-file fullpath)))) ;; verify checksum before operating on untrusted data (el-get-verify-checksum package) ;; unzip `basename url` diff --git a/test/caching-speedtest.el b/test/caching-speedtest.el index 40cd8c45..77c2f167 100644 --- a/test/caching-speedtest.el +++ b/test/caching-speedtest.el @@ -1,6 +1,6 @@ ;; Benchmark for caching the package status alist -(require 'cl) +(require 'cl-lib) (defmacro timeit (&rest body) "Run body and report real time taken to do so." @@ -14,7 +14,7 @@ (defmacro suppress-messages (&rest body) "Run body with `message' redefined as a no-op." - `(flet ((message (&rest ignored) nil)) + `(cl-flet ((message (&rest ignored) nil)) (progn ,@body))) (put 'suppress-messages 'lisp-indent-function (get 'progn 'lisp-indent-function)) @@ -37,7 +37,7 @@ (message "Beginning benchmark") ;; Repeat benchmark 5 times to see consistency (let ((times - (loop + (cl-loop for rep from 1 upto 5 collect (timeit diff --git a/test/el-get-tests.el b/test/el-get-tests.el index 54e59de8..1c58daf2 100644 --- a/test/el-get-tests.el +++ b/test/el-get-tests.el @@ -2,9 +2,9 @@ (require 'ert nil t) (eval-when-compile - (require 'cl) + (require 'cl-lib) (unless (featurep 'ert) - (defmacro* ert-deftest (name () &body docstring-keys-and-body) + (cl-defmacro ert-deftest (name () &body docstring-keys-and-body) (message "Skipping tests, ERT is not available")))) (defvar el-get-test-output-buffer nil) @@ -76,9 +76,9 @@ Following variables are bound to temporal values: (while (file-exists-p f) (setq f (concat f f))) f)))) (should (equal (el-get-recipe-dirs) - (loop for f in el-get-recipe-path - when (file-exists-p f) - collect f))))) + (cl-loop for f in el-get-recipe-path + when (file-exists-p f) + collect f))))) (ert-deftest el-get-trivial-install-test () (el-get-with-temp-home @@ -221,14 +221,14 @@ John.Doe-123_@example.com")) (let* ((github-pkgname "user/dummy.el") (el-get-sources `((:name "dummy" :type github :pkgname ,github-pkgname))) (el-get-allow-insecure nil)) - (letf (((symbol-function 'el-get-package-is-installed) - (lambda (package) - (string= package "dummy"))) - ((symbol-function 'el-get-git-pull) - (lambda (package url post-install) - (should (string= package "dummy")) - (should (string= url (concat "https://github.com/" github-pkgname ".git"))))) - ((symbol-function 'el-get-insecure-check) - (lambda (package url) - (error "Leave 'el-get-insecure-check to git")))) + (cl-letf (((symbol-function 'el-get-package-is-installed) + (lambda (package) + (string= package "dummy"))) + ((symbol-function 'el-get-git-pull) + (lambda (package url post-install) + (should (string= package "dummy")) + (should (string= url (concat "https://github.com/" github-pkgname ".git"))))) + ((symbol-function 'el-get-insecure-check) + (lambda (package url) + (error "Leave 'el-get-insecure-check to git")))) (should (el-get-do-update "dummy"))))) diff --git a/test/test-setup.el b/test/test-setup.el index abc1de93..fd40f185 100644 --- a/test/test-setup.el +++ b/test/test-setup.el @@ -1,5 +1,6 @@ +(require 'debug) (require 'el-get) -(require 'cl) + (setq debugger-batch-max-lines (+ 50 max-lisp-eval-depth) debug-on-error t el-get-verbose t