[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
feature/pkg 5b6ca7fe73 3/3: Add :register to make-package
From: |
Gerd Moellmann |
Subject: |
feature/pkg 5b6ca7fe73 3/3: Add :register to make-package |
Date: |
Wed, 26 Oct 2022 08:16:14 -0400 (EDT) |
branch: feature/pkg
commit 5b6ca7fe73a20bc21eee76e2f92194310331f5c4
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>
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.
---
lisp/emacs-lisp/pkg.el | 8 +++++++-
test/src/pkg-tests.el | 10 +++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/pkg.el b/lisp/emacs-lisp/pkg.el
index 48d6e108dc..044a56a5e2 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 c9127f16d9..875c1fbda8 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