aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authorLars Ingebrigtsen2022-06-05 16:36:25 +0200
committerLars Ingebrigtsen2022-06-05 16:36:34 +0200
commit9d2f4a8d5a92fdfab80ce9faf0dcfa159189916b (patch)
treee594acec129ce3637dd49e22ad8f771e3b247fd7 /admin
parentac6660a2d026e89214814768990d0d232f0a9d06 (diff)
downloademacs-9d2f4a8d5a92fdfab80ce9faf0dcfa159189916b.tar.gz
emacs-9d2f4a8d5a92fdfab80ce9faf0dcfa159189916b.zip
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 @@
89;; PROPn: string representing the nth property value 89;; PROPn: string representing the nth property value
90 90
91(eval-when-compile (require 'cl-lib)) 91(eval-when-compile (require 'cl-lib))
92(require 'generate-file)
92 93
93(defvar unidata-list nil) 94(defvar unidata-list nil)
94 95
@@ -1422,13 +1423,14 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
1422 (or elt (user-error "Unknown output file: %s" basename)) 1423 (or elt (user-error "Unknown output file: %s" basename))
1423 (or noninteractive (message "Generating %s..." file)) 1424 (or noninteractive (message "Generating %s..." file))
1424 (with-temp-file file 1425 (with-temp-file file
1425 (insert ";;; " basename " -*- lexical-binding:t -*- 1426 (generate-file-heading
1426;; " copyright " 1427 basename
1427;; Generated from Unicode data files by unidata-gen.el. 1428 :text (concat copyright " \
1428;; The sources for this file are found in the admin/unidata/ directory in 1429Generated from Unicode data files by unidata-gen.el. \
1429;; the Emacs sources. The Unicode data files are used under the 1430The sources for this file are found in the admin/unidata/ directory in \
1430;; Unicode Terms of Use, as contained in the file copyright.html in that 1431the Emacs sources. The Unicode data files are used under the \
1431;; same directory.\n") 1432Unicode Terms of Use, as contained in the file copyright.html in that \
1433same directory."))
1432 (dolist (proplist (cdr elt)) 1434 (dolist (proplist (cdr elt))
1433 (let ((prop (unidata-prop-prop proplist)) 1435 (let ((prop (unidata-prop-prop proplist))
1434 (index (unidata-prop-index proplist)) 1436 (index (unidata-prop-index proplist))
@@ -1446,21 +1448,15 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
1446 (set-char-table-extra-slot table 3 describer)) 1448 (set-char-table-extra-slot table 3 describer))
1447 (insert (format "(define-char-code-property '%S\n %S\n %S)\n" 1449 (insert (format "(define-char-code-property '%S\n %S\n %S)\n"
1448 prop table docstring)))) 1450 prop table docstring))))
1449 (insert ";; Local Variables:\n" 1451 (generate-file-trailer basename :inhibit-provide t))))
1450 ";; coding: utf-8\n"
1451 ";; version-control: never\n"
1452 ";; no-byte-compile: t\n"
1453 ";; no-update-autoloads: t\n"
1454 ";; End:\n\n"
1455 (format ";;; %s ends here\n" basename)))))
1456 (or noninteractive (message "Generating %s...done" file))) 1452 (or noninteractive (message "Generating %s...done" file)))
1457 1453
1458(defun unidata-gen-charprop (&optional charprop-file text) 1454(defun unidata-gen-charprop (&optional charprop-file text)
1459 (or charprop-file (setq charprop-file (pop command-line-args-left))) 1455 (or charprop-file (setq charprop-file (pop command-line-args-left)))
1460 (with-temp-file charprop-file 1456 (with-temp-file charprop-file
1461 (insert ";; Automatically generated by unidata-gen.el." 1457 (generate-file-heading
1462 " -*- lexical-binding: t -*-\n" 1458 charprop-file
1463 ";; See the admin/unidata/ directory in the Emacs sources.\n") 1459 :text "Automatically generated by unidata-gen.el. See the admin/unidata/ directory in the Emacs sources.")
1464 (if text 1460 (if text
1465 (insert text) 1461 (insert text)
1466 (dolist (elt unidata-file-alist) 1462 (dolist (elt unidata-file-alist)
@@ -1469,19 +1465,7 @@ Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
1469 (unidata-prop-prop proplist) (car elt) 1465 (unidata-prop-prop proplist) (car elt)
1470 (unidata-prop-docstring proplist)))))) 1466 (unidata-prop-docstring proplist))))))
1471 (or noninteractive (message "Writing %s..." charprop-file)) 1467 (or noninteractive (message "Writing %s..." charprop-file))
1472 (insert "\n" 1468 (generate-file-trailer charprop-file)))
1473 (format "(provide '%s)\n"
1474 (file-name-sans-extension
1475 (file-name-nondirectory charprop-file)))
1476 " \n"
1477 ";; Local Variables:\n"
1478 ";; coding: utf-8\n"
1479 ";; version-control: never\n"
1480 ";; no-byte-compile: t\n"
1481 ";; no-update-autoloads: t\n"
1482 ";; End:\n\n"
1483 (format ";;; %s ends here\n"
1484 (file-name-nondirectory charprop-file)))))
1485 1469
1486(defun unidata-gen-scripts (&optional file) 1470(defun unidata-gen-scripts (&optional file)
1487 ;; Running from Makefile. 1471 ;; Running from Makefile.