Remove xetla pkg
[packages] / hack-package-index.el
1 ;;; hack-package-index.el --- Update package-get-base package index file
2
3 ;; Copyright (C) 1998 by Free Software Foundation, Inc.
4
5 ;; Author: SL Baur <steve@xemacs.org>
6 ;; Keywords: internal
7
8 ;; This file is part of XEmacs.
9
10 ;; XEmacs is free software; you can redistribute it and/or modify it
11 ;; under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; any later version.
14
15 ;; XEmacs is distributed in the hope that it will be useful, but
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18 ;; General Public License for more details.
19
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with XEmacs; see the file COPYING.  If not, write to the Free
22 ;; Software Foundation, Inc.,  51 Franklin Street, Fifth Floor, Boston,
23 ;; MA  02110-1301, USA.
24
25 ;;; Synched up with: Not in FSF
26
27 ;;; Commentary:
28
29 ;; usage xemacs -batch -l hack-package-index.el -f batch-hack-package-index \
30 ;;  package-name /path/to/package-info /path/to/package-get-base.el
31
32 ;;; Code:
33
34 (defvar end-of-package-marker ";;;@@@"
35   "Marker in between entries.")
36
37 (defun locate-package-entry (name)
38   (goto-char (point-min))
39   (if (re-search-forward
40        (concat "^(package-get-update-base-entry (quote\n(" name "$") nil t)
41       (let ((from (match-beginning 0)))
42         (re-search-forward (concat "^" end-of-package-marker "$"))
43         (delete-region from (1+ (point-at-eol))))
44     (re-search-forward (concat "^" end-of-package-marker "$"))
45     (forward-char)))
46
47 (defun convert-crlf ()
48   "Convert CRLF to LF."
49   (save-excursion
50     (goto-char (point-min))
51     (while (search-forward "\r\n" nil t)
52       (replace-match "\n" t t))))
53
54 (defun batch-hack-package-index ()
55   (let* ((package-name (pop command-line-args-left))
56          (package-info (pop command-line-args-left))
57          (package-get-base (pop command-line-args-left)))
58     (set-buffer (get-buffer-create "*package index*"))
59     (when (file-exists-p package-get-base)
60       (insert-file-contents-literally package-get-base))
61     (when (eq (point-min) (point-max))
62       (insert ";; Package Index file -- Do not edit manually.\n")
63       (insert end-of-package-marker "\n")
64       (insert ";; Package Index file ends here\n"))
65     (locate-package-entry package-name)
66     (insert "))\n")
67     (insert end-of-package-marker "\n")
68     (forward-line -2)
69     (insert "(package-get-update-base-entry (quote\n")
70     (let ((length
71            (second (insert-file-contents-literally package-info))))
72       (save-restriction
73         (narrow-to-region (point) (+ (point) length))
74         (convert-crlf)))
75     (write-file package-get-base)))
76
77 (provide 'hack-package-index)
78
79 ;;; hack-package-index.el ends here