From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#13291: The package description buffer needs an URL button Date: Sun, 13 Jan 2013 12:04:33 +0400 Message-ID: <50F26A91.1090905@yandex.ru> References: <50DDAF17.7020602@yandex.ru> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080104070301070004080806" X-Trace: ger.gmane.org 1358064304 12288 80.91.229.3 (13 Jan 2013 08:05:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 13 Jan 2013 08:05:04 +0000 (UTC) Cc: 13291@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Jan 13 09:05:21 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TuIZD-0006Vv-4n for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Jan 2013 09:05:19 +0100 Original-Received: from localhost ([::1]:36658 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuIYw-00017W-JR for geb-bug-gnu-emacs@m.gmane.org; Sun, 13 Jan 2013 03:05:02 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:42540) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuIYm-000176-LS for bug-gnu-emacs@gnu.org; Sun, 13 Jan 2013 03:04:59 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TuIYg-00036z-4Y for bug-gnu-emacs@gnu.org; Sun, 13 Jan 2013 03:04:52 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:52133) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TuIYf-00036n-Vu for bug-gnu-emacs@gnu.org; Sun, 13 Jan 2013 03:04:46 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TuIYw-0008QW-Fx for bug-gnu-emacs@gnu.org; Sun, 13 Jan 2013 03:05:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 13 Jan 2013 08:05:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13291 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 13291-submit@debbugs.gnu.org id=B13291.135806429932383 (code B ref 13291); Sun, 13 Jan 2013 08:05:02 +0000 Original-Received: (at 13291) by debbugs.gnu.org; 13 Jan 2013 08:04:59 +0000 Original-Received: from localhost ([127.0.0.1]:57597 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TuIYs-0008QG-UE for submit@debbugs.gnu.org; Sun, 13 Jan 2013 03:04:59 -0500 Original-Received: from mail-wg0-f46.google.com ([74.125.82.46]:53363) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TuIYp-0008Q2-V8 for 13291@debbugs.gnu.org; Sun, 13 Jan 2013 03:04:57 -0500 Original-Received: by mail-wg0-f46.google.com with SMTP id dr13so1470307wgb.1 for <13291@debbugs.gnu.org>; Sun, 13 Jan 2013 00:04:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type; bh=AVgwzUiBijDnx3TMLMuk+GWYp3TMQxeHDXo0PaNkq4Q=; b=My+rZ877vy0q8RkznpsXB4/BTQ+QoZ3hQV0/i5A7jwLHNQBIU7tpwYheAGU+aMmPUt aaO5FmtvNfjEzFq0AUamX7obIiczAWz5H862593GEKbjjRK1RlsCKA6i4gyac8I2aHlO dxcraoBScqlWl2NnWhZKFnJJcq1ukRy3J98fcFE6SUjbwgP3m1rg7nfUXooTGBARLFqe WMPXpQdBMNblMZNwZdbP4qG5+McMbzTcKGAmsQaTl2VDAwvZErYkZakMKusEOO9hXYza Akn/kOG3MskRZfyQzDQSPzcAp7POnsmH75okmLR2/Ot73J9N3oDls2T+lbZPyEhyCoQW zN6Q== X-Received: by 10.180.82.41 with SMTP id f9mr6628276wiy.25.1358064273286; Sun, 13 Jan 2013 00:04:33 -0800 (PST) Original-Received: from [127.0.0.1] ([178.252.98.87]) by mx.google.com with ESMTPS id g2sm7716220wiy.0.2013.01.13.00.04.30 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 13 Jan 2013 00:04:31 -0800 (PST) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130107 Thunderbird/17.0.2 In-Reply-To: X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:69701 Archived-At: This is a multi-part message in MIME format. --------------080104070301070004080806 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit And here's the updated patch for package.el, with saving the new metadata to -pkg.el file when a single-file package is being installed, and with support for it in `package-install-file'. Again, probably less tested that it should be. --------------080104070301070004080806 Content-Type: text/plain; charset=windows-1251; name="package-homepage-button.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="package-homepage-button.diff" === modified file 'lisp/ChangeLog' --- lisp/ChangeLog 2013-01-12 19:24:27 +0000 +++ lisp/ChangeLog 2013-01-13 07:54:01 +0000 @@ -1,3 +1,27 @@ +2013-01-13 Dmitry Gutov + + * emacs-lisp/package.el (package-desc-kind): Get the kind from the + metadata plist. + (package-desc-meta): Return metadata plist. + (define-package): Store EXTRA-PROPERTIES as the 4th element of + the package data vector. + (package--add-to-archive-contents): Instead of just package kind, + use the 4th element of the vector for the matadata. Include kind + in the metadata. + (describe-package-1): When the package metadata includes + `:homepage', display a link button for it (bug#13291). + (package-unpack-single): Accept a 5th argument, with metadata. + Appent it to the `define-package' form. + (package-download-single): Accept and pass on the META argument. + (package-download-transaction): Pass the package metadata to + `package-download-single'. + (package-buffer-info): Return the package metadata (currently with + just homepage) as the 6th vector argument. + (package-tar-file-info): Same. Like most of the elements of the + returned vector, though, it won't be used by the caller. + (package-install-from-buffer): Get package metadata from PKG-INFO + and pass it to `package-unpack-single'. + 2013-01-12 Michael Albinus * autorevert.el (auto-revert-notify-watch-descriptor): Give it === modified file 'lisp/emacs-lisp/package.el' --- lisp/emacs-lisp/package.el 2013-01-01 09:11:05 +0000 +++ lisp/emacs-lisp/package.el 2013-01-13 07:44:34 +0000 @@ -170,6 +170,7 @@ ;;; Code: (require 'tabulated-list) +(require 'cl-lib) (defgroup package nil "Manager for Emacs Lisp packages." @@ -302,12 +303,13 @@ Each element has the form (PKG . DESC), where PKG is a package name (a symbol) and DESC is a vector that describes the package. -The vector DESC has the form [VERSION-LIST REQS DOCSTRING]. +The vector DESC has the form [VERSION-LIST REQS DOCSTRING META]. VERSION-LIST is a version list. REQS is a list of packages required by the package, each requirement having the form (NAME VL) where NAME is a string and VL is a version list. DOCSTRING is a brief description of the package. + META is a property list mapping metadata keywords to values. This variable is set automatically by `package-load-descriptor', called via `package-initialize'. To change which packages are @@ -426,6 +428,10 @@ (defsubst package-desc-kind (desc) "Extract the kind of download from an archive package description vector." + (plist-get (package-desc-meta desc) :kind)) + +(defsubst package-desc-meta (desc) + "Extract the metadata property list from a package description vector." (aref desc 3)) (defun package--dir (name version) @@ -525,7 +531,7 @@ (defun define-package (name-string version-string &optional docstring requirements - &rest _extra-properties) + &rest extra-properties) "Define a new package. NAME-STRING is the name of the package, as a string. VERSION-STRING is the version of the package, as a string. @@ -533,8 +539,8 @@ REQUIREMENTS is a list of dependencies on other packages. Each requirement is of the form (OTHER-PACKAGE OTHER-VERSION), where OTHER-VERSION is a string. - -EXTRA-PROPERTIES is currently unused." +EXTRA-PROPERTIES is a property list mapping additional metadata +keywords (e.g. `:homepage') to values." (let* ((name (intern name-string)) (version (version-to-list version-string)) (new-pkg-desc @@ -545,7 +551,8 @@ (list (car elt) (version-to-list (car (cdr elt))))) requirements) - docstring))) + docstring + extra-properties))) (old-pkg (assq name package-alist))) (cond ;; If there's no old package, just add this to `package-alist'. @@ -642,7 +649,7 @@ (let ((buffer-file-coding-system 'no-conversion)) (write-region (point-min) (point-max) file-name))) -(defun package-unpack-single (file-name version desc requires) +(defun package-unpack-single (file-name version desc requires meta) "Install the contents of the current buffer as a package." ;; Special case "package". (if (string= file-name "package") @@ -661,17 +668,19 @@ (write-region (concat (prin1-to-string - (list 'define-package - file-name - version - desc - (list 'quote - ;; Turn version lists into string form. - (mapcar - (lambda (elt) - (list (car elt) - (package-version-join (cadr elt)))) - requires)))) + (nconc + (list 'define-package + file-name + version + desc + (list 'quote + ;; Turn version lists into string form. + (mapcar + (lambda (elt) + (list (car elt) + (package-version-join (cadr elt)))) + requires))) + meta)) "\n") nil pkg-file @@ -721,12 +730,12 @@ (end-of-line) (point))))))) -(defun package-download-single (name version desc requires) +(defun package-download-single (name version desc requires meta) "Download and install a single-file package." (let ((location (package-archive-base name)) (file (concat (symbol-name name) "-" version ".el"))) (package--with-work-buffer location file - (package-unpack-single (symbol-name name) version desc requires)))) + (package-unpack-single (symbol-name name) version desc requires meta)))) (defun package-download-tar (name version) "Download and install a tar package." @@ -853,8 +862,15 @@ Also, add the originating archive to the end of the package vector." (let* ((name (car package)) (version (package-desc-vers (cdr package))) + (data (append (cdr package) nil)) + (ex-len (- (length data) 3)) + (extras (last data ex-len)) (entry (cons name - (vconcat (cdr package) (vector archive)))) + (vconcat (nbutlast data ex-len) + ;; Save the kind and any following + ;; keyword-value pairs as metadata. + (vector (cons :kind extras) + archive)))) (existing-package (assq name package-archive-contents))) (cond ((not existing-package) (add-to-list 'package-archive-contents entry)) @@ -886,7 +902,8 @@ ((eq kind 'single) (package-download-single elt v-string (package-desc-doc desc) - (package-desc-reqs desc))) + (package-desc-reqs desc) + (package-desc-meta desc))) (t (error "Unknown package kind: %s" (symbol-name kind)))) ;; If package A depends on package B, then A may `require' B @@ -942,7 +959,7 @@ "Return a vector describing the package in the current buffer. The vector has the form - [FILENAME REQUIRES DESCRIPTION VERSION COMMENTARY] + [FILENAME REQUIRES DESCRIPTION VERSION COMMENTARY META] FILENAME is the file name, a string, sans the \".el\" extension. REQUIRES is a list of requirements, each requirement having the @@ -950,6 +967,7 @@ DESCRIPTION is the package description, a string. VERSION is the version, a string. COMMENTARY is the commentary section, a string, or nil if none. +META is a property list with additional metadata. If the buffer does not contain a conforming package, signal an error. If there is a package, narrow the buffer to the file's @@ -975,7 +993,8 @@ (pkg-version (or (package-strip-rcs-id (lm-header "package-version")) (package-strip-rcs-id (lm-header "version")))) - (commentary (lm-commentary))) + (commentary (lm-commentary)) + (homepage (lm-homepage))) (unless pkg-version (error "Package lacks a \"Version\" or \"Package-Version\" header")) @@ -986,7 +1005,8 @@ (list (car elt) (version-to-list (car (cdr elt))))) requires)) - (vector file-name requires desc pkg-version commentary)))) + (vector file-name requires desc pkg-version commentary + (list :homepage homepage))))) (defun package-tar-file-info (file) "Find package information for a tar file. @@ -1013,6 +1033,7 @@ (version-string (nth 2 pkg-def-parsed)) (docstring (nth 3 pkg-def-parsed)) (requires (nth 4 pkg-def-parsed)) + (meta (cdr (cl-cddddr pkg-def-parsed))) (readme (shell-command-to-string ;; Requires GNU tar. (concat "tar -xOf " file " " @@ -1032,7 +1053,7 @@ (list (car elt) (version-to-list (cadr elt)))) requires)) - (vector pkg-name requires docstring version-string readme))))) + (vector pkg-name requires docstring version-string readme meta))))) ;;;###autoload (defun package-install-from-buffer (pkg-info type) @@ -1052,14 +1073,15 @@ (desc (if (string= (aref pkg-info 2) "") "No description available." (aref pkg-info 2))) - (pkg-version (aref pkg-info 3))) + (pkg-version (aref pkg-info 3)) + (meta (aref pkg-info 5))) ;; Download and install the dependencies. (let ((transaction (package-compute-transaction nil requires))) (package-download-transaction transaction)) ;; Install the package itself. (cond ((eq type 'single) - (package-unpack-single file-name pkg-version desc requires)) + (package-unpack-single file-name pkg-version desc requires meta)) ((eq type 'tar) (package-unpack (intern file-name) pkg-version)) (t @@ -1261,7 +1283,13 @@ (help-insert-xref-button text 'help-package name)) (insert "\n"))) (insert " " (propertize "Summary" 'font-lock-face 'bold) - ": " (if desc (package-desc-doc desc)) "\n\n") + ": " (if desc (package-desc-doc desc)) "\n") + (let ((homepage (plist-get (package-desc-meta desc) :homepage))) + (when homepage + (insert " " (propertize "Homepage" 'font-lock-face 'bold) ": ") + (help-insert-xref-button homepage 'help-url homepage) + (insert "\n"))) + (insert "\n") (if built-in ;; For built-in packages, insert the commentary. --------------080104070301070004080806--