Fix computation of regex stack limit
[emacs.git] / admin / ldefs-clean.el
blob6eabe57c7e4c64a4b08855f37d4e916d7270c28d
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/>.
18 ;;; Commentary:
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."
26 (save-excursion
27 (goto-char beg)
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."
33 (interactive)
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."
38 (interactive)
39 (goto-char (point-max))
40 ;; We only need the autoloads up till loaddefs.el is
41 ;; generated. After this, ldefs-boot.el is not needed
42 (search-backward " GEN loaddefs.el")
43 (delete-region (point) (point-max))
44 (keep-lines "(autoload" (point-min) (point-max))
45 (sort-lines nil (point-min) (point-max))
46 (ldefs-clean-uniquify-buffer-lines)
47 (goto-char (point-min))
48 (insert
49 ";; This file is autogenerated by admin/ldefs-clean.el
50 ;; Do not edit
52 (goto-char (point-max))
53 (insert
54 ";; Local Variables:
55 ;; no-byte-compile: t
56 ;; no-update-autoloads: t
57 ;; End:"))
60 (defun ldefs-clean ()
61 (find-file "lisp/ldefs-boot-auto.temp")
62 (ldefs-clean-up)
63 (write-file "ldefs-boot-auto.el"))