Skip to content

Commit

Permalink
[maybe] package-build-expand-files-spec: Support renaming files expli…
Browse files Browse the repository at this point in the history
…citly

[maybe:]
At the same time remove support for implicitly renaming "*.el.in"
files to "*.el".  It is better if package maintainers are aware
that they are doing something out of the ordinary by having to
deal with it explicitly.

Currently this affect a whooping number of two packages on Melpa.

IMO we should not implicitly rename files.  On the other hand, if we
make it possible to make arbitrary renames, then package authors might
actually start using that for other renames, which would be very
unfortunate.  No renames should ever be necessary and my preference
would be to get the two remaining packages that rely on the .el.in to
.el renaming to stop doing that, and then drop support for this
completely.
  • Loading branch information
tarsius committed Sep 1, 2024
1 parent 6148407 commit a102152
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions package-build.el
Original file line number Diff line number Diff line change
Expand Up @@ -1229,6 +1229,13 @@ order and can have the following form:
A string is glob-expanded to match zero or more files. Matched
files are copied to the top-level directory.
- (:rename SRC DST)
A list that begins with `:rename' causes the file SRC to be
renamed and/or moved to DEST. SRC and DEST are relative file
names (as opposed to globs) and both may contain directory
parts. SRC must exist.
- (SUBDIRECTORY GLOB...)
A list that begins with a string causes the files matched by
Expand Down Expand Up @@ -1265,10 +1272,12 @@ order and can have the following form:
SPEC is a full files spec as stored in a recipe object."
(let (include exclude)
(dolist (entry spec)
(if (eq (car-safe entry) :exclude)
(dolist (entry (cdr entry))
(push entry exclude))
(push entry include)))
(pcase (car-safe entry)
(:exclude
(dolist (entry (cdr entry))
(push entry exclude)))
(:rename (push entry include))
(_ (push entry include))))
(cl-set-difference
(package-build--expand-files-spec-2 (nreverse include))
(package-build--expand-files-spec-2 (nreverse exclude))
Expand All @@ -1280,17 +1289,20 @@ If SUBDIR is nil, use `default-directory'. SPEC is expected to
be a partial files spec, consisting of either all include rules
or all exclude rules (with the `:exclude' keyword removed)."
(mapcan (lambda (entry)
(if (stringp entry)
(mapcar (lambda (f)
(cons f
(concat subdir
(replace-regexp-in-string
"\\.el\\.in\\'" ".el"
(file-name-nondirectory f)))))
(file-expand-wildcards entry))
(package-build--expand-files-spec-2
(cond
((stringp entry)
(mapcar (lambda (f)
(cons f
(concat subdir
(replace-regexp-in-string
"\\.el\\.in\\'" ".el"
(file-name-nondirectory f)))))
(file-expand-wildcards entry)))
((eq (car-safe entry) :rename)
(list (cons (nth 1 entry) (nth 2 entry))))
((package-build--expand-files-spec-2
(cdr entry)
(concat subdir (car entry) "/"))))
(concat subdir (car entry) "/")))))
spec))

(defun package-build--copy-package-files (files target-dir)
Expand Down

0 comments on commit a102152

Please sign in to comment.