Subject: More flexible package dependency specification

From: Tom Willemse <[email-masked]>
Date: Fri, 16 Aug 2013 22:58:18 +0200

What would you think of the attached patch? It works for all the
examples I sent earlier. Any comments, criticisms and considerations
would be greatly appreciated.

*** lisp/ChangeLog	2013-08-16 22:53:18.590328000 +0200
--- lisp/ChangeLog.new	2013-08-16 22:45:04.548991805 +0200
***************
*** 1,3 ****
--- 1,11 ----
+ 2013-08-16  Tom Willemse  <[email-masked]>
+ 
+ 	* emacs-lisp/package.el (package--prepare-dependencies): New
+ 	function.
+ 	(package-buffer-info): Call `package--prepare-dependencies' on the
+ 	list contained in the package-requires header to make dependency
+ 	specification a little more flexible.
+ 
  2013-08-16  Lars Magne Ingebrigtsen  <[email-masked]>
  
  	* net/shr.el (shr-rescale-image): Use ImageMagick even for GIFs
*** lisp/emacs-lisp/package.el	2013-08-16 22:53:18.590328000 +0200
--- lisp/emacs-lisp/package.el.new	2013-08-16 22:52:51.479137603 +0200
***************
*** 973,978 ****
--- 973,989 ----
  	    str)
        (error nil))))
  
+ (defun package--prepare-dependencies (deps)
+   "Turn DEPS into an acceptable list of dependencies.
+ 
+ Any parts missing a version string get a default version string
+ of \"0\" (meaning any version) and an appropriate level of lists
+ is wrapped around any parts requiring it."
+   (cond
+    ((symbolp deps) `((,deps "0")))
+    ((stringp (cadr deps)) `(,deps))
+    (t (mapcar (lambda (dep) (if (symbolp dep) `(,dep "0") dep)) deps))))
+ 
  (defun package-buffer-info ()
    "Return a `package-desc' describing the package in the current buffer.
  
***************
*** 1003,1009 ****
  	 "Package lacks a \"Version\" or \"Package-Version\" header"))
        (package-desc-from-define
         file-name pkg-version desc
!        (if requires-str (package-read-from-string requires-str))
         :kind 'single))))
  
  (declare-function tar-get-file-descriptor "tar-mode" (file))
--- 1014,1022 ----
  	 "Package lacks a \"Version\" or \"Package-Version\" header"))
        (package-desc-from-define
         file-name pkg-version desc
!        (if requires-str
!            (package--prepare-dependencies
!             (package-read-from-string requires-str)))
         :kind 'single))))
  
  (declare-function tar-get-file-descriptor "tar-mode" (file))