From 9c08f0d108dc948a575db68da9548bfba515187a Mon Sep 17 00:00:00 2001 From: Gerd Moellmann Date: Tue, 5 Sep 2023 07:57:29 +0200 Subject: [PATCH] Function buffer-package --- lisp/emacs-lisp/pkg.el | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lisp/emacs-lisp/pkg.el b/lisp/emacs-lisp/pkg.el index 6962421f61e..9e09daf0617 100644 --- a/lisp/emacs-lisp/pkg.el +++ b/lisp/emacs-lisp/pkg.el @@ -177,13 +177,14 @@ Otherwise assume that " (error "%s does not contain a symbol %s" (package-name package) name)))) -(defun buffer-package (buffer) - "Return the value of *package* in BUFFER. +(cl-defun buffer-package (&optional (buffer (current-buffer))) + "Return the value of *package* set in BUFFER. BUFFER must be either a buffer object or the name of an existing buffer." - (buffer-local-value '*package* - (if (bufferp buffer) - buffer - (get-buffer buffer)))) + (let ((buffer (if (bufferp buffer) + buffer + (get-buffer buffer)))) + (with-current-buffer buffer + (default-buffer-local-value '*package*)))) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Macros -- 2.39.2