diff options
author | Philip Kaludercic <philipk@posteo.net> | 2023-05-07 21:37:01 +0200 |
---|---|---|
committer | Philip Kaludercic <philipk@posteo.net> | 2023-05-12 09:41:55 +0200 |
commit | 6fa9332e7cdb28c3990f8d1444b02b65791713d6 (patch) | |
tree | 64bbd49054e1cfb8b68bb7aaf3d31faf94152727 /lisp/emacs-lisp | |
parent | 60d5a015d1fb6f10439c80d3b0733de88c204d6c (diff) | |
download | emacs-6fa9332e7cdb28c3990f8d1444b02b65791713d6.tar.gz |
Ensure that EXTRA-DATA are always written when generating autoloads
* lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate): Handle
edge-case where no autoloads are found. (Bug#63260)
Diffstat (limited to 'lisp/emacs-lisp')
-rw-r--r-- | lisp/emacs-lisp/loaddefs-gen.el | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 2a46fb7a022..5db9af21508 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -656,7 +656,20 @@ instead of just updating them with the new/changed autoloads." (write-region (point-min) (point-max) loaddefs-file nil 'silent) (byte-compile-info (file-relative-name loaddefs-file (car (ensure-list dir))) - t "GEN"))))))) + t "GEN"))))) + + ;; If processing files without any autoloads, the above loop will + ;; not generate any files. If the function was invoked with + ;; EXTRA-DATA, we want to ensure that even if no autoloads were + ;; found, that at least a file will have been generated containing + ;; the contents of EXTRA-DATA: + (when (and extra-data (not (file-exists-p output-file))) + (with-temp-buffer + (insert (loaddefs-generate--rubric output-file nil t)) + (search-backward "\f") + (insert extra-data) + (ensure-empty-lines 1) + (write-region (point-min) (point-max) output-file nil 'silent))))) (defun loaddefs-generate--print-form (def) "Print DEF in a format that makes sense for version control." |