Add a :defaults "macro" to the :files spec.

This allows users to add files to the default file list without
overwriting it. For instance:

(example :fetcher example :url "http://example.com/"
         :files (:defaults "an.example"))

This would fetch Emacs Lisp (except tests) and Texinfo files, just like
the defaults, but unlike the defaults, the file an.example would be
included too.

:defaults is only recognized when it's the first element of :files.

Fixes #2275.
This commit is contained in:
Fanael Linithien 2014-12-16 14:20:55 +01:00
parent 3af3905e1c
commit c097cc4282
2 changed files with 13 additions and 1 deletions

View file

@ -246,6 +246,11 @@ to the root of the package.* More complex options are available,
submit an [Issue](https://github.com/milkypostman/melpa/issues) if the submit an [Issue](https://github.com/milkypostman/melpa/issues) if the
specified package requires more complex file specification. specified package requires more complex file specification.
If the the package merely requires some additional files, for example for
bundling external dependencies, but is otherwise fine with the defaults, it's
recommended to use `:defaults` as the very first element of this list, which
causes the default value shown above to be prepended to the specified file list.
[git]: http://git-scm.com/ [git]: http://git-scm.com/
[github]: https://github.com/ [github]: https://github.com/
[bzr]: http://bazaar.canonical.com/en/ [bzr]: http://bazaar.canonical.com/en/

View file

@ -848,7 +848,14 @@ for ALLOW-EMPTY to prevent this error."
(defun pb/config-file-list (config) (defun pb/config-file-list (config)
"Get the :files spec from CONFIG, or return `package-build-default-files-spec'." "Get the :files spec from CONFIG, or return `package-build-default-files-spec'."
(or (plist-get config :files) package-build-default-files-spec)) (let ((file-list (plist-get config :files)))
(cond
((null file-list)
package-build-default-files-spec)
((eq :default (car file-list))
(append package-build-default-files-spec (cdr file-list)))
(t
file-list))))
(defun pb/expand-source-file-list (dir config) (defun pb/expand-source-file-list (dir config)
"Shorthand way to expand paths in DIR for source files listed in CONFIG." "Shorthand way to expand paths in DIR for source files listed in CONFIG."