1 ;; Copyright (C) 2016-2017 Free Software Foundation, Inc.
3 ;; This file is part of GNU Emacs.
5 ;; GNU Emacs is free software: you can redistribute it and/or modify
6 ;; it under the terms of the GNU General Public License as published by
7 ;; the Free Software Foundation, either version 3 of the License, or
8 ;; (at your option) any later version.
10 ;; GNU Emacs is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ;; GNU General Public License for more details.
15 ;; You should have received a copy of the GNU General Public License
16 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
20 ;; This file takes the output from the "generate-ldefs-boot" make
21 ;; target, takes the relevant autoload forms, removes everything else
22 ;; and adds some comments.
24 (defun ldefs-clean-uniquify-region-lines (beg end
)
25 "Remove duplicate adjacent lines in region."
28 (while (re-search-forward "^\\(.*\n\\)\\1+" end t
)
29 (replace-match "\\1"))))
31 (defun ldefs-clean-uniquify-buffer-lines ()
32 "Remove duplicate adjacent lines in the current buffer."
34 (ldefs-clean-uniquify-region-lines (point-min) (point-max)))
36 (defun ldefs-clean-up ()
37 "Clean up output from build and turn it into ldefs-boot-auto.el."
39 (goto-char (point-max))
40 ;; We need to record autoloads till the point that emacs (as opposed
41 ;; to bootstrap-emacs) is dumped. After this point, we are not
42 ;; bootstrapping any more.
43 (search-backward "-l loadup dump")
45 (delete-region (point) (point-max))
46 (keep-lines "(autoload" (point-min) (point-max))
47 (sort-lines nil
(point-min) (point-max))
48 (ldefs-clean-uniquify-buffer-lines)
49 (goto-char (point-min))
51 ";; This file is autogenerated by admin/ldefs-clean.el
54 (goto-char (point-max))
58 ;; no-update-autoloads: t
63 (find-file "lisp/ldefs-boot-auto.temp")
65 (write-file "ldefs-boot-auto.el"))