From: Gerd Möllmann Date: Wed, 26 Oct 2022 12:08:57 +0000 (+0200) Subject: Add :register to make-package X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=5b6ca7fe73a20bc21eee76e2f92194310331f5c4;p=emacs.git Add :register to make-package * lisp/emacs-lisp/pkg.el (make-package): Add keyword argument :register. If true, add new package to package registry. * test/src/pkg-tests.el (pkg-tests-make-package): Extend. --- diff --git a/lisp/emacs-lisp/pkg.el b/lisp/emacs-lisp/pkg.el index 48d6e108dc0..044a56a5e2c 100644 --- a/lisp/emacs-lisp/pkg.el +++ b/lisp/emacs-lisp/pkg.el @@ -264,7 +264,8 @@ normally, or else if an explcit return occurs the value it transfers." ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;###autoload -(cl-defun make-package (name &key nicknames use (size 10)) +(cl-defun make-package (name &key nicknames use (size 10) + (register nil)) "Create and return a new package with name NAME. NAME must be a string designator, that is a string, a symbol, or @@ -285,6 +286,9 @@ the given name is created. SIZE gives the size to use for the symbol table of the new package. Default is 10. +REGISTER if true means register the package in the package +registry. + Please note that the newly created package is not automaticall registered in the package registry, that is it will not be found under its names by `find-package'. Use `register-package' to @@ -297,6 +301,8 @@ but is what Common Lisp implementations usually do." (package (make-%package name size))) (setf (package-%nicknames package) nicknames (package-%use-list package) use) + (when register + (register-package package)) package)) (defun register-package (package) diff --git a/test/src/pkg-tests.el b/test/src/pkg-tests.el index c9127f16d91..875c1fbda82 100644 --- a/test/src/pkg-tests.el +++ b/test/src/pkg-tests.el @@ -72,7 +72,15 @@ (should-error (make-package "x" :nicknames)) (should-error (make-package "x" :use)) (should-error (make-package "x" :nicknames 1)) - (should-error (make-package "x" :use 1))) + (should-error (make-package "x" :use 1)) + ;; Registering package + (let ((p (make-package "x" :nicknames '(y) :register t))) + (unwind-protect + (progn + (should (packagep p)) + (should (eq (find-package "x") p)) + (should (eq (find-package "y") p))) + (delete-package p)))) (ert-deftest pkg-tests-make-package-nicknames () ;; Valid nicknames