1 ;;; prv-install.el --- Complicated install-time magic for preview-latex.
3 ;; Copyright (C) 2002, 2005 Free Software Foundation, Inc.
5 ;; Author: David Kastrup
6 ;; Keywords: convenience, tex, wp
8 ;; This file is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 3, or (at your option)
13 ;; This file is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
25 ;; This contains package-building stuff and other install-time magic.
26 ;; It may well contain Emacs-version-specific code, but certain
27 ;; functions here should be *callable* from any Emacs version.
31 (defun preview-make-package ()
32 "Do anything required to make a package in this version of Emacs,
33 other than actually copying the Lisp files.
35 Takes arguments on the comamnd line: the package directory and any
36 number of Lisp files to generate autoloads from.
38 Does nothing in Emacsen that do not support a package system."
39 (if (featurep 'xemacs)
40 (preview-make-package-xemacs))
41 (setq command-line-args-left nil))
43 (defun preview-make-package-xemacs ()
44 "Do anything required to make a package in XEmacs,
45 other than actually copying the Lisp files.
47 Generates auto-autoloads, custom-loads, and package metadata file
48 in the right locations. Takes from the command line the package directory,
49 package name, and version (to be evaluated), followed by a file to append."
50 (let* ((package-dir (pop command-line-args-left))
51 (package-name (pop command-line-args-left))
52 (release-version (eval (read (pop command-line-args-left))))
53 (author-version (eval (read (pop command-line-args-left))))
55 (lisp-dir (expand-file-name (format "lisp/%s/" package-name)
57 (metadata (expand-file-name "_pkg.el" lisp-dir))
58 (custom-load (expand-file-name "custom-load.el" lisp-dir))
59 (generated-autoload-file (expand-file-name "auto-autoloads.el"
61 (si:message (symbol-function 'message))
62 make-backup-files noninteractive)
63 ;; Delete and regenerate the custom-load file.
64 (when (file-exists-p custom-load)
65 (delete-file custom-load))
66 (when (file-exists-p (concat custom-load "c"))
67 (delete-file (concat custom-load "c")))
68 (Custom-make-dependencies lisp-dir)
69 (when (file-exists-p custom-load)
71 (byte-compile-file custom-load))
72 ; Delete and regenerate the package metadata file.
73 ; There is no compiled form of this file.
74 (message "Updating metadata for the directory %s..." lisp-dir)
75 (with-temp-file metadata
77 (concat ";;;###autoload\n"
78 "(package-provide '" package-name "\n"
82 "\"" author-version "\"\n"
83 " :type 'regular)\n")))
84 ; Delete and regenerate the auto-autoloads file.
85 (message "Updating autoloads for the directory %s..." lisp-dir)
86 (when (file-exists-p generated-autoload-file)
87 (delete-file generated-autoload-file))
88 (when (file-exists-p (concat generated-autoload-file "c"))
89 (delete-file (concat generated-autoload-file "c")))
90 (defun message (fmt &rest args)
91 "Ignore useless messages while generating autoloads."
92 (cond ((and (string-equal "Generating autoloads for %s..." fmt)
93 (file-exists-p (file-name-nondirectory (car args))))
95 fmt (file-name-nondirectory (car args))))
96 ((string-equal "No autoloads found in %s" fmt))
97 ((string-equal "Generating autoloads for %s...done" fmt))
98 (t (apply si:message fmt args))))
100 (cond ((fboundp 'update-autoloads-from-directory)
101 (update-autoloads-from-directory lisp-dir))
102 ((fboundp 'update-autoload-files)
103 (update-autoload-files (list lisp-dir) "auctex"))
104 (t (error "Failed to generate autoloads.")))
105 (fset 'message si:message))
106 (while (setq append-file (pop command-line-args-left))
107 (when (file-exists-p generated-autoload-file)
108 (with-temp-buffer (insert-file append-file)
109 (append-to-file (point-min) (point-max)
110 generated-autoload-file))))
111 (byte-compile-file generated-autoload-file)))
114 ;;; prv-install.el ends here