[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] master 32e4119: * emacs-lisp/package.el (package-get-versi
From: |
Stefan Monnier |
Subject: |
[Emacs-diffs] master 32e4119: * emacs-lisp/package.el (package-get-version): Change into a function |
Date: |
Fri, 19 Oct 2018 18:10:47 -0400 (EDT) |
branch: master
commit 32e411943d3f1d1546bfcb1aad8c4d4cd28857d6
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>
* emacs-lisp/package.el (package-get-version): Change into a function
(package-quickstart-refresh): Mangle string so it doesn't turn into
a false positive for "no-byte-compile: t".
---
etc/NEWS | 2 +-
lisp/emacs-lisp/package.el | 8 ++++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/etc/NEWS b/etc/NEWS
index b906467..09f0362 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -420,7 +420,7 @@ This enables more efficient backends. See the docstring of
** Package
-*** New macro `package-get-version` lets packages query their own version.
+*** New function `package-get-version` lets packages query their own version.
Example use in auctex.el: (defconst auctex-version (package-get-version))
*** New 'package-quickstart' feature.
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 06e9956..9c4c3e9 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -3452,11 +3452,14 @@ The list is displayed in a buffer named `*Packages*'."
(list-packages t))
;;;###autoload
-(defmacro package-get-version ()
+(defun package-get-version ()
"Return the version number of the package in which this is used.
Assumes it is used from an Elisp file placed inside the top-level directory
of an installed ELPA package.
The return value is a string (or nil in case we can't find it)."
+ ;; In a sense, this is a lie, but it does just what we want: precompute
+ ;; the version at compile time and hardcodes it into the .elc file!
+ (declare (pure t))
;; Hack alert!
(let ((file
(or (if (boundp 'byte-compile-current-file) byte-compile-current-file)
@@ -3476,6 +3479,7 @@ The return value is a string (or nil in case we can't
find it)."
(pkgname (file-name-nondirectory (directory-file-name pkgdir)))
(mainfile (expand-file-name (concat pkgname ".el") pkgdir)))
(when (file-readable-p mainfile)
+ (require 'lisp-mnt)
(with-temp-buffer
(insert-file-contents mainfile)
(or (lm-header "package-version")
@@ -3567,7 +3571,7 @@ activations need to be changed, such as when
`package-load-list' is modified."
(insert "
;; Local\sVariables:
;; version-control: never
-;; no-byte-compile: t
+;;\sno-byte-compile: t
;; no-update-autoloads: t
;; End:
"))))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] master 32e4119: * emacs-lisp/package.el (package-get-version): Change into a function,
Stefan Monnier <=