Ensure that byte compilation works for relative files (Bug#45287).

* lisp/emacs-lisp/bytecomp.el (byte-compile-file): Don’t fail if
target filename doesn’t contain a directory name.

* test/lisp/emacs-lisp/bytecomp-tests.el
(bytecomp-tests--target-file-no-directory): New unit test.
This commit is contained in:
Philipp Stephani 2020-12-17 12:06:15 +01:00
parent 32d76c0cbc
commit 7fad959114
2 changed files with 20 additions and 1 deletions

View file

@ -1967,7 +1967,11 @@ See also `emacs-lisp-byte-compile-and-load'."
;; We attempt to create a temporary file in the
;; target directory, so the target directory must be
;; writable.
(file-writable-p (file-name-directory target-file)))
(file-writable-p
(file-name-directory
;; Need to expand in case TARGET-FILE doesn't
;; include a directory (Bug#45287).
(expand-file-name target-file))))
;; We must disable any code conversion here.
(let* ((coding-system-for-write 'no-conversion)
;; Write to a tempfile so that if another Emacs