summaryrefslogtreecommitdiff
path: root/admin
diff options
context:
space:
mode:
authorLars Ingebrigtsen <larsi@gnus.org>2022-06-05 16:36:25 +0200
committerLars Ingebrigtsen <larsi@gnus.org>2022-06-05 16:36:34 +0200
commit9d2f4a8d5a92fdfab80ce9faf0dcfa159189916b (patch)
treee594acec129ce3637dd49e22ad8f771e3b247fd7 /admin
parentac6660a2d026e89214814768990d0d232f0a9d06 (diff)
downloademacs-9d2f4a8d5a92fdfab80ce9faf0dcfa159189916b.tar.gz
Add convenience functions for generating Emacs Lisp files
* lisp/url/url-cookie.el (url-cookie-write-file): * lisp/international/titdic-cnv.el (tit-process-header): * lisp/international/ja-dic-cnv.el (skkdic-convert): * lisp/international/emoji.el (emoji--generate-file): * lisp/emacs-lisp/loaddefs-gen.el (loaddefs-generate--rubric) * admin/unidata/unidata-gen.el (unidata-gen-file) (unidata-gen-charprop): Use the new functions. * lisp/emacs-lisp/generate-file.el: New file to provide convenience functions for generated files. It's not always trivial to know which parts of the trailer that has to be obfuscated to avoid not getting byte-compiled etc, and some parts of the headers/trailers are usually forgotten when hand-coding these.
Diffstat (limited to 'admin')
-rw-r--r--admin/unidata/unidata-gen.el44
1 files changed, 14 insertions, 30 deletions
diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el
index 149f7535588..dc8c071999e 100644
--- a/admin/unidata/unidata-gen.el
+++ b/admin/unidata/unidata-gen.el
@@ -89,6 +89,7 @@
;; PROPn: string representing the nth property value
(eval-when-compile (require 'cl-lib))
+(require 'generate-file)
(defvar unidata-list nil)
@@ -1422,13 +1423,14 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
(or elt (user-error "Unknown output file: %s" basename))
(or noninteractive (message "Generating %s..." file))
(with-temp-file file
- (insert ";;; " basename " -*- lexical-binding:t -*-
-;; " copyright "
-;; Generated from Unicode data files by unidata-gen.el.
-;; The sources for this file are found in the admin/unidata/ directory in
-;; the Emacs sources. The Unicode data files are used under the
-;; Unicode Terms of Use, as contained in the file copyright.html in that
-;; same directory.\n")
+ (generate-file-heading
+ basename
+ :text (concat copyright " \
+Generated from Unicode data files by unidata-gen.el. \
+The sources for this file are found in the admin/unidata/ directory in \
+the Emacs sources. The Unicode data files are used under the \
+Unicode Terms of Use, as contained in the file copyright.html in that \
+same directory."))
(dolist (proplist (cdr elt))
(let ((prop (unidata-prop-prop proplist))
(index (unidata-prop-index proplist))
@@ -1446,21 +1448,15 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
(set-char-table-extra-slot table 3 describer))
(insert (format "(define-char-code-property '%S\n %S\n %S)\n"
prop table docstring))))
- (insert ";; Local Variables:\n"
- ";; coding: utf-8\n"
- ";; version-control: never\n"
- ";; no-byte-compile: t\n"
- ";; no-update-autoloads: t\n"
- ";; End:\n\n"
- (format ";;; %s ends here\n" basename)))))
+ (generate-file-trailer basename :inhibit-provide t))))
(or noninteractive (message "Generating %s...done" file)))
(defun unidata-gen-charprop (&optional charprop-file text)
(or charprop-file (setq charprop-file (pop command-line-args-left)))
(with-temp-file charprop-file
- (insert ";; Automatically generated by unidata-gen.el."
- " -*- lexical-binding: t -*-\n"
- ";; See the admin/unidata/ directory in the Emacs sources.\n")
+ (generate-file-heading
+ charprop-file
+ :text "Automatically generated by unidata-gen.el. See the admin/unidata/ directory in the Emacs sources.")
(if text
(insert text)
(dolist (elt unidata-file-alist)
@@ -1469,19 +1465,7 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
(unidata-prop-prop proplist) (car elt)
(unidata-prop-docstring proplist))))))
(or noninteractive (message "Writing %s..." charprop-file))
- (insert "\n"
- (format "(provide '%s)\n"
- (file-name-sans-extension
- (file-name-nondirectory charprop-file)))
- " \n"
- ";; Local Variables:\n"
- ";; coding: utf-8\n"
- ";; version-control: never\n"
- ";; no-byte-compile: t\n"
- ";; no-update-autoloads: t\n"
- ";; End:\n\n"
- (format ";;; %s ends here\n"
- (file-name-nondirectory charprop-file)))))
+ (generate-file-trailer charprop-file)))
(defun unidata-gen-scripts (&optional file)
;; Running from Makefile.