1 ;;; hack-package-index.el --- Update package-get-base package index file
3 ;; Copyright (C) 1998 by Free Software Foundation, Inc.
5 ;; Author: SL Baur <steve@xemacs.org>
8 ;; This file is part of XEmacs.
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)
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.
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.
25 ;;; Synched up with: Not in FSF
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
34 (defvar end-of-package-marker ";;;@@@"
35 "Marker in between entries.")
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 "$"))
47 (defun convert-crlf ()
50 (goto-char (point-min))
51 (while (search-forward "\r\n" nil t)
52 (replace-match "\n" t t))))
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)
67 (insert end-of-package-marker "\n")
69 (insert "(package-get-update-base-entry (quote\n")
71 (second (insert-file-contents-literally package-info))))
73 (narrow-to-region (point) (+ (point) length))
75 (write-file package-get-base)))
77 (provide 'hack-package-index)
79 ;;; hack-package-index.el ends here