Extract :url and :keywords to package info

This commit is contained in:
Sebastian Wiesner 2014-04-02 15:35:51 +02:00
parent f59685b098
commit b7d29cb544

View file

@ -836,13 +836,31 @@ FILES is a list of (SOURCE . DEST) relative filepath pairs."
"Return a vector of package info.
`package-buffer-info' returns a vector in older Emacs versions,
and a cl struct in Emacs HEAD. This wrapper normalises the results."
(let ((desc (package-buffer-info)))
(let ((desc (package-buffer-info))
(keywords (lm-keywords-list)))
(if (fboundp 'package-desc-create)
(vector (package-desc-name desc)
(package-desc-reqs desc)
(package-desc-summary desc)
(package-desc-version desc))
desc)))
(let ((extras (package-desc-extras desc)))
(when (and keywords (not (assq :keywords extras)))
;; Add keywords to package properties, if not already present
(push (cons :keywords keywords) extras))
(vector (package-desc-name desc)
(package-desc-reqs desc)
(package-desc-summary desc)
(package-desc-version desc)
extras))
;; The regexp and the processing is taken from `lm-homepage' in Emacs 24.4
(let* ((page (lm-header "\\(?:x-\\)?\\(?:homepage\\|url\\)"))
(homepage (if (and page (string-match "^<.+>$" page))
(substring page 1 -1)
page))
extras)
(when keywords (push (cons :keywords keywords) extras))
(when homepage (push (cons :url homepage) extras))
(vector (aref desc 0)
(aref desc 1)
(aref desc 2)
(aref desc 3)
extras)))))
;;; Public interface