Function: package-buffer-info
package-buffer-info is a byte-compiled function defined in
package.el.gz.
Signature
(package-buffer-info)
Documentation
Return a package-desc describing the package in the current buffer.
If the buffer does not contain a conforming package, signal an error. If there is a package, narrow the buffer to the file's boundaries.
Source Code
;; Defined in /usr/src/emacs/lisp/emacs-lisp/package.el.gz
(defun package-buffer-info ()
"Return a `package-desc' describing the package in the current buffer.
If the buffer does not contain a conforming package, signal an
error. If there is a package, narrow the buffer to the file's
boundaries."
(goto-char (point-min))
(unless (re-search-forward "^;;; \\([^ ]*\\)\\.el ---[ \t]*\\(.*?\\)[ \t]*\\(-\\*-.*-\\*-[ \t]*\\)?$" nil t)
(error "Package lacks a file header"))
(let ((file-name (match-string-no-properties 1))
(desc (match-string-no-properties 2))
(start (line-beginning-position)))
(require 'lisp-mnt)
;; This warning was added in Emacs 27.1, and should be removed at
;; the earliest in version 31.1. The idea is to phase out the
;; requirement for a "footer line" without unduly impacting users
;; on earlier Emacs versions. See Bug#26490 for more details.
(unless (search-forward (concat ";;; " file-name ".el ends here") nil 'move)
;; Starting in Emacs 30.1, avoid warning if the minimum Emacs
;; version is specified as 30.1 or later.
(let ((min-emacs (cadar (seq-filter (lambda (x) (eq (car x) 'emacs))
(lm-package-requires)))))
(when (or (null min-emacs)
(version< min-emacs "30.1"))
(lwarn '(package package-format) :warning
"Package lacks a terminating comment"))))
;; Try to include a trailing newline.
(forward-line)
(narrow-to-region start (point))
;; Use some headers we've invented to drive the process.
(let* (;; Prefer Package-Version; if defined, the package author
;; probably wants us to use it. Otherwise try Version.
(version-info
(or (lm-header "package-version") (lm-header "version")))
(pkg-version (package-strip-rcs-id version-info))
(keywords (lm-keywords-list))
(website (lm-website)))
(unless pkg-version
(if version-info
(error "Unrecognized package version: %s" version-info)
(error "Package lacks a \"Version\" or \"Package-Version\" header")))
(package-desc-from-define
file-name pkg-version desc
(lm-package-requires)
:kind 'single
:url website
:keywords keywords
:maintainer
;; For backward compatibility, use a single cons-cell if
;; there's only one maintainer (the most common case).
(let ((maints (lm-maintainers))) (if (cdr maints) maints (car maints)))
:authors (lm-authors)))))