From 9d7207bbef4fd3d0a90b25422e175c54488eee54 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gerd=20M=C3=B6llmann?= Date: Thu, 27 Oct 2022 14:12:20 +0200 Subject: [PATCH] Minto cleanup in pkg.el * lisp/emacs-lisp/pkg.el (pkg--check-name-conflicts): Removed. (pkg--add-to-registry): Removed. (register-package): Add code of the removed functions. (rename-package): Use register-package. --- lisp/emacs-lisp/pkg.el | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/lisp/emacs-lisp/pkg.el b/lisp/emacs-lisp/pkg.el index f20d51e721e..96c73a09217 100644 --- a/lisp/emacs-lisp/pkg.el +++ b/lisp/emacs-lisp/pkg.el @@ -148,19 +148,6 @@ Otherwise, NAME must be the name of a registered package." (or (find-package pkg-name) (error "No package %s found" name))))) -(defun pkg--check-name-conflicts (package) - (cl-flet ((check (name) - (when (gethash name *package-registry*) - (error "%s conflicts with existing package" name)))) - (check (package-%name package)) - (dolist (n (package-%nicknames package)) (check n)))) - -(defun pkg--add-to-registry (package) - (pkg--check-name-conflicts package) - (puthash (package-%name package) package *package-registry*) - (mapc (lambda (name) (puthash name package *package-registry*)) - (package-%nicknames package))) - (cl-defun pkg--remove-from-registry (package) "Remove PACKAGE from the package registry." ;; Note that an unregistered package might have the same name or @@ -311,9 +298,15 @@ Signal an error if the name or one of the nicknames of PACKAGE conflicts with a name already present in the registry. Value is PACKAGE." (let ((package (pkg--package-or-lose package))) - (pkg--check-name-conflicts package) - (pkg--add-to-registry package) - package)) + (cl-flet ((check (name) + (when (gethash name *package-registry*) + (error "%s conflicts with existing package" name)))) + (check (package-%name package)) + (mapc #'check (package-%nicknames package)) + (puthash (package-%name package) package *package-registry*) + (mapc (lambda (name) (puthash name package *package-registry*)) + (package-%nicknames package)) + package))) ;;;###autoload (defun list-all-packages () @@ -424,7 +417,7 @@ Value is the renamed package object." (pkg--remove-from-registry package) (setf (package-%nicknames package) new-nicknames) (setf (package-%name package) new-name) - (pkg--add-to-registry package) + (register-package package) package)) ;;;###autoload -- 2.39.2