From: Gerd Moellmann Date: Wed, 6 Sep 2023 06:20:49 +0000 (+0200) Subject: with-locked-packages, with-unlocked-packages X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f6a1411e83f1b2222c1a486d2775c2129b61d81e;p=emacs.git with-locked-packages, with-unlocked-packages --- diff --git a/.gitignore b/.gitignore index ca89bc47f79..fcdb1ae38f0 100644 --- a/.gitignore +++ b/.gitignore @@ -388,3 +388,4 @@ exec/config.h.in exec/config-mips.m4 exec/configure exec/*.s.s +/nextstep/Pkg.app/ diff --git a/lisp/emacs-lisp/pkg.el b/lisp/emacs-lisp/pkg.el index 4b2ca980902..aea6d3712a9 100644 --- a/lisp/emacs-lisp/pkg.el +++ b/lisp/emacs-lisp/pkg.el @@ -284,12 +284,21 @@ normally, or else if an explcit return occurs the value it transfers." (progn ,@body))) ;;;###autoload -(cl-defmacro with-unlocked-packages ((&rest _packages) &body body) - ) +(defun pkg--with-package-locks (packages lock body) + `(cl-letf (,@(mapcar #'(lambda (p) + `((package-%lock (pkg--package-or-lose ,p)) ,lock)) + packages)) + ,@body)) ;;;###autoload -(cl-defmacro with-locked-packages ((&rest _packages) &body body) - ) +(cl-defmacro with-unlocked-packages ((&rest packages) &rest body) + (declare (indent 1)) + (pkg--with-package-locks packages nil body)) + +;;;###autoload +(cl-defmacro with-locked-packages ((&rest packages) &rest body) + (declare (indent 1)) + (pkg--with-package-locks packages t body)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;