From be6dbd4b1ea00be1d63121cdc05d61424129a6ba Mon Sep 17 00:00:00 2001 From: Artur Malabarba Date: Mon, 12 Jan 2015 23:24:22 -0200 Subject: [PATCH] * emacs-lisp/package.el (package--read-pkg-desc): New function. Read a `define-package' form in current buffer. Return the pkg-desc, with desc-kind set to KIND. --- lisp/ChangeLog | 6 ++++++ lisp/emacs-lisp/package.el | 26 ++++++++++++++++---------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/lisp/ChangeLog b/lisp/ChangeLog index c80f8f7bad4..93796e67a3d 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog @@ -1,3 +1,9 @@ +2015-01-16 Artur Malabarba + + * emacs-lisp/package.el (package--read-pkg-desc): New + function. Read a `define-package' form in current buffer. Return + the pkg-desc, with desc-kind set to KIND. + 2015-01-16 Jorgen Schaefer * emacs-lisp/package.el: Provide repository priorities. diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el index 5336271b65b..d5906675596 100644 --- a/lisp/emacs-lisp/package.el +++ b/lisp/emacs-lisp/package.el @@ -1277,19 +1277,25 @@ The return result is a `package-desc'." (unless tar-desc (error "No package descriptor file found")) (with-current-buffer (tar--extract tar-desc) - (goto-char (point-min)) (unwind-protect - (let* ((pkg-def-parsed (read (current-buffer))) - (pkg-desc - (if (not (eq (car pkg-def-parsed) 'define-package)) - (error "Can't find define-package in %s" - (tar-header-name tar-desc)) - (apply #'package-desc-from-define - (append (cdr pkg-def-parsed)))))) - (setf (package-desc-kind pkg-desc) 'tar) - pkg-desc) + (package--read-pkg-desc 'tar) (kill-buffer (current-buffer)))))) +(defun package--read-pkg-desc (kind) + "Read a `define-package' form in current buffer. +Return the pkg-desc, with desc-kind set to KIND." + (goto-char (point-min)) + (unwind-protect + (let* ((pkg-def-parsed (read (current-buffer))) + (pkg-desc + (if (not (eq (car pkg-def-parsed) 'define-package)) + (error "Can't find define-package in %s" + (tar-header-name tar-desc)) + (apply #'package-desc-from-define + (append (cdr pkg-def-parsed)))))) + (setf (package-desc-kind pkg-desc) kind) + pkg-desc))) + ;;;###autoload (defun package-install-from-buffer () -- 2.39.2