From c097cc4282d868d5a3722fc5512f628cac9277a8 Mon Sep 17 00:00:00 2001 From: Fanael Linithien Date: Tue, 16 Dec 2014 14:20:55 +0100 Subject: [PATCH] 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. --- README.md | 5 +++++ package-build.el | 9 ++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d9fe4f32..451c99e6 100644 --- a/README.md +++ b/README.md @@ -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 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/ [github]: https://github.com/ [bzr]: http://bazaar.canonical.com/en/ diff --git a/package-build.el b/package-build.el index 4bcb03e2..a6778a69 100644 --- a/package-build.el +++ b/package-build.el @@ -848,7 +848,14 @@ for ALLOW-EMPTY to prevent this error." (defun pb/config-file-list (config) "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) "Shorthand way to expand paths in DIR for source files listed in CONFIG."