;; Helpers
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defun pkg--check-package-lock (package)
+ (when (and (package-locked-p package)
+ enable-package-locks)
+ (error "Package %s is locked" (package-name package))))
+
(defun pkg--check-disjoint (&rest args)
"Check whether all given arguments specify disjoint sets of symbols.
Each argument is of the form (:key . set)."
(if (bufferp buffer)
buffer
(get-buffer buffer))))
-\f
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Macros
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
,var
,result-form))))
+(defun pkg--internal-symbols (package)
+ (let (syms)
+ (do-symbols (sym (pkg--package-or-lose package))
+ (when (eq (symbol-package sym) *emacs-user-package*)
+ (push sym syms)))
+ syms))
+
+(defun pkg--external-symbols (package)
+ (let (syms)
+ (do-external-symbols (sym (pkg--package-or-lose package))
+ (when (eq (symbol-package sym) *emacs-user-package*)
+ (push sym syms)))
+ syms))
+
+(cl-defmacro without-package-locks (&body body)
+ `(let ((enable-package-locks nil))
+ (progn ,@body)))
+
+(cl-defmacro with-unlocked-packages ((&rest _packages) &body body)
+ )
\f
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Basic stuff
(new-name (pkg--stringify-name new-name "package name"))
(new-nicknames (pkg--stringify-names new-nicknames
"package nickname")))
+ (pkg--check-package-lock package)
(unless (package-%name package)
(error "Package is deleted"))
(pkg--remove-from-registry package)
Fremhash (symbol, PACKAGE_SYMBOLS (package));
}
+static void
+pkg_check_package_lock (Lisp_Object package)
+{
+ if (!NILP (Venable_package_locks))
+ if (!NILP (XPACKAGE (package)->lock))
+ error ("Package %s is locked", SDATA (XPACKAGE (package)->name));
+}
+
/* Intern a symbol with name NAME to PACKAGE. If a symbol with name
NAME is already accessible in PACKAGE, return that symbol.
symbol = existing_symbol;
else
{
- if (!NILP (XPACKAGE (package)->lock))
- error ("Package %s is locked", SDATA (XPACKAGE (package)->name));
+ pkg_check_package_lock (package);
symbol = Fmake_symbol (name);
}
staticpro (&Vsymbol_packages);
Vsymbol_packages = Qnil;
+ staticpro (&Venable_package_locks);
+ Venable_package_locks = Qt;
+
pkg_define_builtin_symbols ();
}
DEFVAR_LISP_NOPRO ("symbol-packages", Vsymbol_packages,
doc: /* */);
Fmake_variable_buffer_local (Qsymbol_packages);
+ DEFVAR_LISP_NOPRO ("enable-package-locks", Venable_package_locks,
+ doc: /* */);
Fprovide (Qsymbol_packages, Qnil);
}