From f6a1411e83f1b2222c1a486d2775c2129b61d81e Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Wed, 6 Sep 2023 08:20:49 +0200 Subject: [PATCH] with-locked-packages, with-unlocked-packages --- .gitignore | 1 + lisp/emacs-lisp/pkg.el | 17 +++++++++++++---- 2 files changed, 14 insertions(+), 4 deletions(-) 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)) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -- 2.39.2