1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-15 09:47:20 +00:00
emacs/admin/ldefs-clean.el
Phillip Lord c27b645956 Replace ldefs-boot with a much smaller file
* Makefile.in (bootstrap-build,generate-ldefs-boot): New targets.
   (bootstrap): Depend on bootstrap-build.
 * admin/ldefs-clean.el: New file.
 * lisp/Makefile.in (compile-first): Depend on loaddefs.el
 * lisp/ldefs-boot.el: Remove.
 * lisp/ldefs-boot-auto.el: New file.
 * lisp/ldefs-boot-manual.el: New file.
 * lisp/loadup.el: Load ldefs-boot-manual.el.
 * src/emacs.c (generating_ldefs_boot): New variable.
   (main): Check whether we are generating ldefs.
 * src/eval.c (autoload-do-load): Dump autoload forms to stderr when
   requested.
 * src/lisp.h (generating_ldefs_boot): New variable.
 * admin/gitmerge.el, admin/make-tarball.txt, admin/notes/copyright,
   lisp/Makefile.in, lisp/cus-dep.el, lisp/emacs-lisp/elint.el,
   lisp/finder.el, lisp/loadup.el, msdos/mainmake.v2: Update reference to
   ldefs-boot.
 * admin/update_autogen: Alter mechanism for ldefs-boot generation.
2016-12-13 22:15:32 +00:00

64 lines
2.1 KiB
EmacsLisp

;; Copyright (C) 2016 Free Software Foundation, Inc.
;; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
;;; Commentary:
;; This file takes the output from the "generate-ldefs-boot" make
;; target, takes the relevant autoload forms, removes everything else
;; and adds some comments.
(defun ldefs-clean-uniquify-region-lines (beg end)
"Remove duplicate adjacent lines in region."
(save-excursion
(goto-char beg)
(while (re-search-forward "^\\(.*\n\\)\\1+" end t)
(replace-match "\\1"))))
(defun ldefs-clean-uniquify-buffer-lines ()
"Remove duplicate adjacent lines in the current buffer."
(interactive)
(ldefs-clean-uniquify-region-lines (point-min) (point-max)))
(defun ldefs-clean-up ()
"Clean up output from build and turn it into ldefs-boot-auto.el."
(interactive)
(goto-char (point-max))
;; We only need the autoloads up till loaddefs.el is
;; generated. After this, ldefs-boot.el is not needed
(search-backward " GEN loaddefs.el")
(delete-region (point) (point-max))
(keep-lines "(autoload" (point-min) (point-max))
(sort-lines nil (point-min) (point-max))
(ldefs-clean-uniquify-buffer-lines)
(goto-char (point-min))
(insert
";; This file is autogenerated by admin/ldefs-clean.el
;; Do not edit
")
(goto-char (point-max))
(insert
";; Local Variables:
;; no-byte-compile: t
;; no-update-autoloads: t
;; End:"))
(defun ldefs-clean ()
(find-file "lisp/ldefs-boot-auto.temp")
(ldefs-clean-up)
(write-file "ldefs-boot-auto.el"))