From 98d454627ca2e9a6cdb906895b044e7221db3f2f Mon Sep 17 00:00:00 2001 From: Lars Ingebrigtsen Date: Sun, 5 Jun 2022 17:48:29 +0200 Subject: [PATCH] Rename generate-file to generate-lisp-file * lisp/url/url-cookie.el (url-cookie-write-file): * lisp/international/titdic-cnv.el (tit-process-header) (miscdic-convert): * 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): Adjust callers. * lisp/emacs-lisp/generate-lisp-file.el: Renamed from generate-file.el. Also rename some keyword parameters and require a generator function. --- admin/unidata/unidata-gen.el | 19 +++++++------- ...generate-file.el => generate-lisp-file.el} | 26 ++++++++++--------- lisp/emacs-lisp/loaddefs-gen.el | 17 ++++++------ lisp/international/emoji.el | 6 ++--- lisp/international/ja-dic-cnv.el | 9 +++---- lisp/international/titdic-cnv.el | 14 ++++------ lisp/url/url-cookie.el | 4 +-- 7 files changed, 46 insertions(+), 49 deletions(-) rename lisp/emacs-lisp/{generate-file.el => generate-lisp-file.el} (82%) diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el index dc8c071999e..0a9fd5108ce 100644 --- a/admin/unidata/unidata-gen.el +++ b/admin/unidata/unidata-gen.el @@ -89,7 +89,7 @@ ;; PROPn: string representing the nth property value (eval-when-compile (require 'cl-lib)) -(require 'generate-file) +(require 'generate-lisp-file) (defvar unidata-list nil) @@ -1423,10 +1423,9 @@ 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 - (generate-file-heading - basename - :text (concat copyright " \ -Generated from Unicode data files by unidata-gen.el. \ + (generate-lisp-file-heading + basename 'unidata-gen-file + :commentary (concat copyright " \ 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 \ @@ -1448,15 +1447,15 @@ same directory.")) (set-char-table-extra-slot table 3 describer)) (insert (format "(define-char-code-property '%S\n %S\n %S)\n" prop table docstring)))) - (generate-file-trailer basename :inhibit-provide t)))) + (generate-lisp-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 - (generate-file-heading - charprop-file - :text "Automatically generated by unidata-gen.el. See the admin/unidata/ directory in the Emacs sources.") + (generate-lisp-file-heading + charprop-file 'unidata-gen-charprop + :commentary "See the admin/unidata/ directory in the Emacs sources.") (if text (insert text) (dolist (elt unidata-file-alist) @@ -1465,7 +1464,7 @@ same directory.")) (unidata-prop-prop proplist) (car elt) (unidata-prop-docstring proplist)))))) (or noninteractive (message "Writing %s..." charprop-file)) - (generate-file-trailer charprop-file))) + (generate-lisp-file-trailer charprop-file))) (defun unidata-gen-scripts (&optional file) ;; Running from Makefile. diff --git a/lisp/emacs-lisp/generate-file.el b/lisp/emacs-lisp/generate-lisp-file.el similarity index 82% rename from lisp/emacs-lisp/generate-file.el rename to lisp/emacs-lisp/generate-lisp-file.el index 456503df6a3..8896a3f7019 100644 --- a/lisp/emacs-lisp/generate-file.el +++ b/lisp/emacs-lisp/generate-lisp-file.el @@ -1,4 +1,4 @@ -;;; generate-file.el --- utility functions for generated files -*- lexical-binding: t -*- +;;; generate-lisp-file.el --- utility functions for generated files -*- lexical-binding: t -*- ;; Copyright (C) 2022 Free Software Foundation, Inc. @@ -26,17 +26,18 @@ (eval-when-compile (require 'cl-lib)) -(cl-defun generate-file-heading (file &key description text (code t)) - "Insert a standard header for FILE. +(cl-defun generate-lisp-file-heading (file generator + &key title commentary (code t)) + "Insert a standard header for FILE created by GENERATOR. This header will specify that this is a generated file that should not be edited. If `standard-output' is bound to a buffer, insert in that buffer. If no, insert at point in the current buffer. -DESCRIPTION (if any) will be used in the first line. +TITLE (if any) will be used in the first line. -TEXT (if given) will be inserted as a comment. +COMMENTARY (if given) will be inserted as a comment. If CODE is non-nil (which is the default), a Code: line is inserted." @@ -45,21 +46,22 @@ inserted." (current-buffer)) (insert ";;; " (file-name-nondirectory file) " --- " - (or description "automatically generated") + (or title "automatically generated") " (do not edit) " - " -*- lexical-binding: t -*-\n\n" + " -*- lexical-binding: t -*-\n" + (format ";; Generated by the `%s' function.\n\n" generator) ";; This file is part of GNU Emacs.\n\n") - (when text + (when commentary (insert ";;; Commentary:\n\n") (let ((start (point)) (fill-prefix ";; ")) - (insert ";; " text) + (insert ";; " commentary) (fill-region start (point)))) (ensure-empty-lines 1) (when code (insert ";;; Code:\n\n")))) -(cl-defun generate-file-trailer (file &key version inhibit-provide +(cl-defun generate-lisp-file-trailer (file &key version inhibit-provide (coding 'utf-8-emacs-unix) autoloads compile provide) "Insert a standard trailer for FILE. @@ -106,6 +108,6 @@ If no, insert at point in the current buffer." ";; End:\n\n" ";;; " (file-name-nondirectory file) " ends here\n"))) -(provide 'generate-file) +(provide 'generate-lisp-file) -;;; generate-file.el ends here +;;; generate-lisp-file.el ends here diff --git a/lisp/emacs-lisp/loaddefs-gen.el b/lisp/emacs-lisp/loaddefs-gen.el index 9aa2967d7b3..7661f60e0ba 100644 --- a/lisp/emacs-lisp/loaddefs-gen.el +++ b/lisp/emacs-lisp/loaddefs-gen.el @@ -40,7 +40,7 @@ (require 'radix-tree) (require 'lisp-mnt) -(require 'generate-file) +(require 'generate-lisp-file) (defvar autoload-compute-prefixes t "If non-nil, autoload will add code to register the prefixes used in a file. @@ -440,17 +440,18 @@ be a string naming the feature, otherwise it will be based on FILE's name." (let ((lp (and (equal type "package") (setq type "autoloads")))) (with-temp-buffer - (generate-file-heading - file - :description (concat "automatically extracted " (or type "autoloads")) - :text (and (string-match "/lisp/loaddefs\\.el\\'" file) - "This file will be copied to ldefs-boot.el and checked in periodically.")) + (generate-lisp-file-heading + file 'loaddefs-generate--rubric + :title (concat "automatically extracted " (or type "autoloads")) + :commentary (and (string-match "/lisp/loaddefs\\.el\\'" file) + "This file will be copied to ldefs-boot.el and checked in periodically.")) (when lp (insert "(add-to-list 'load-path (directory-file-name (or (file-name-directory #$) (car load-path))))\n\n")) (insert " \n;;; End of scraped data\n\n") - (generate-file-trailer file :provide (and (stringp feature) feature) - :inhibit-provide (not feature)) + (generate-lisp-file-trailer + file :provide (and (stringp feature) feature) + :inhibit-provide (not feature)) (buffer-string)))) (defun loaddefs-generate--insert-section-header (outbuf autoloads diff --git a/lisp/international/emoji.el b/lisp/international/emoji.el index d53b01173d5..8970a466b7c 100644 --- a/lisp/international/emoji.el +++ b/lisp/international/emoji.el @@ -31,7 +31,7 @@ (require 'cl-extra) (require 'transient) (require 'multisession) -(require 'generate-file) +(require 'generate-lisp-file) (defgroup emoji nil "Inserting Emojis." @@ -416,7 +416,7 @@ the name is not known." (dolist (glyph glyphs) (remhash glyph emoji--derived))) (with-temp-buffer - (generate-file-heading file) + (generate-lisp-file-heading file 'emoji--generate-file) (insert ";; Copyright © 1991-2021 Unicode, Inc. ;; Generated from Unicode data files by emoji.el. ;; The source for this file is found in the admin/unidata/emoji-test.txt @@ -427,7 +427,7 @@ the name is not known." (insert (format "(defconst %s '" var)) (pp (symbol-value var) (current-buffer)) (insert (format "\n) ;; End %s\n\n" var))) - (generate-file-trailer file) + (generate-lisp-file-trailer file) (write-region (point-min) (point-max) file))) (defun emoji--base-name (name derivations) diff --git a/lisp/international/ja-dic-cnv.el b/lisp/international/ja-dic-cnv.el index 563eba6682b..1bbc664e756 100644 --- a/lisp/international/ja-dic-cnv.el +++ b/lisp/international/ja-dic-cnv.el @@ -44,7 +44,7 @@ ;;; Code: -(require 'generate-file) +(require 'generate-lisp-file) ;; Name of a file to generate from SKK dictionary. (defvar ja-dic-filename "ja-dic.el") @@ -342,9 +342,8 @@ Saves the output as `ja-dic-filename', in directory DIRNAME (if specified)." (with-current-buffer buf (erase-buffer) (buffer-disable-undo) - (generate-file-heading ja-dic-filename :code nil) - (insert ";;\tGenerated by the `skkdic-convert' function.\n" - ";;\tOriginal SKK dictionary file: " + (generate-lisp-file-heading ja-dic-filename 'skkdic-convert :code nil) + (insert ";; Original SKK dictionary file: " (file-relative-name (expand-file-name filename) dirname) "\n\n" ";;; Start of the header of the original SKK dictionary.\n\n") @@ -394,7 +393,7 @@ Saves the output as `ja-dic-filename', in directory DIRNAME (if specified)." ;; Postfix (with-current-buffer buf (goto-char (point-max)) - (generate-file-trailer ja-dic-filename :compile t))) + (generate-lisp-file-trailer ja-dic-filename :compile t))) ;; Save the working buffer. (set-buffer buf) diff --git a/lisp/international/titdic-cnv.el b/lisp/international/titdic-cnv.el index bdb77ca7026..2a91e7cb5ec 100644 --- a/lisp/international/titdic-cnv.el +++ b/lisp/international/titdic-cnv.el @@ -62,7 +62,7 @@ ;;; Code: (require 'quail) -(require 'generate-file) +(require 'generate-lisp-file) ;; List of values of key "ENCODE:" and the corresponding Emacs ;; coding-system and language environment name. @@ -270,12 +270,10 @@ SPC, 6, 3, 4, or 7 specifying a tone (SPC:陰平, 6:陽平, 3:上聲, 4:去聲, (tit-moveleft ",<") (tit-keyprompt nil)) - (generate-file-heading filename :code nil) + (generate-lisp-file-heading filename 'titdic-convert :code nil) (princ ";; Quail package `") (princ package) (princ "\n") - (princ (substitute-command-keys - ";; Generated by the `titdic-convert' function.\n")) (princ ";;\tOriginal TIT dictionary file: ") (princ (file-name-nondirectory filename)) (princ "\n\n") @@ -521,7 +519,7 @@ the generated Quail package is saved." ;; Process the body part (tit-process-body) - (generate-file-trailer + (generate-lisp-file-trailer filename :inhibit-provide t :compile t :coding nil)))))) ;;;###autoload @@ -1132,10 +1130,8 @@ the generated Quail package is saved." ;; Explicitly set eol format to `unix'. (setq coding-system-for-write 'utf-8-unix) (with-temp-file (expand-file-name quailfile dirname) - (generate-file-heading quailfile) + (generate-lisp-file-heading quailfile 'miscdic-convert) (insert (format-message ";; Quail package `%s'\n" name)) - (insert (format-message - ";; Generated by the `miscdic-convert' function.\n")) (insert ";; Source dictionary file: " dicfile "\n") (insert ";; Copyright notice of the source file\n") (insert ";;------------------------------------------------------\n") @@ -1157,7 +1153,7 @@ the generated Quail package is saved." (let ((dicbuf (current-buffer))) (with-current-buffer dstbuf (funcall converter dicbuf))))) - (generate-file-trailer + (generate-lisp-file-trailer quailfile :inhibit-provide t :compile t :coding nil))) (setq tail (cdr tail))))) diff --git a/lisp/url/url-cookie.el b/lisp/url/url-cookie.el index dab367485e9..15c78512c64 100644 --- a/lisp/url/url-cookie.el +++ b/lisp/url/url-cookie.el @@ -26,7 +26,7 @@ (require 'url-util) (require 'url-parse) (require 'url-domsuf) -(require 'generate-file) +(require 'generate-lisp-file) (eval-when-compile (require 'cl-lib)) @@ -159,7 +159,7 @@ i.e. 1970-1-1) are loaded as expiring one year from now instead." (insert ")\n(setq url-cookie-secure-storage\n '") (pp url-cookie-secure-storage (current-buffer))) (insert ")\n") - (generate-file-trailer fname :inhibit-provide t :autoloads t) + (generate-lisp-file-trailer fname :inhibit-provide t :autoloads t) (setq-local version-control 'never) (write-file fname)) (setq url-cookies-changed-since-last-save nil)))) -- 2.39.2