+(defun dgnushack-make-auto-load ()
+ (require 'autoload)
+ (unless (make-autoload '(define-derived-mode child parent name
+ "docstring" body)
+ "file")
+ (defadvice make-autoload (around handle-define-derived-mode activate)
+ "Handle `define-derived-mode'."
+ (if (eq (car-safe (ad-get-arg 0)) 'define-derived-mode)
+ (setq ad-return-value
+ (list 'autoload
+ (list 'quote (nth 1 (ad-get-arg 0)))
+ (ad-get-arg 1)
+ (nth 4 (ad-get-arg 0))
+ t nil))
+ ad-do-it))
+ (put 'define-derived-mode 'doc-string-elt 3))
+ (let ((generated-autoload-file dgnushack-gnus-load-file)
+ (make-backup-files nil)
+ (autoload-package-name "gnus"))
+ (if (featurep 'xemacs)
+ (if (file-exists-p generated-autoload-file)
+ (delete-file generated-autoload-file))
+ (with-temp-file generated-autoload-file
+ (insert ?\014)))
+ (if (featurep 'xemacs)
+ (let ((si:message (symbol-function 'message)))
+ (defun message (fmt &rest args)
+ (cond ((and (string-equal "Generating autoloads for %s..." fmt)
+ (file-exists-p (file-name-nondirectory (car args))))
+ (funcall si:message
+ fmt (file-name-nondirectory (car args))))
+ ((string-equal "No autoloads found in %s" fmt))
+ ((string-equal "Generating autoloads for %s...done" fmt))
+ (t (apply si:message fmt args))))
+ (unwind-protect
+ (batch-update-autoloads)
+ (fset 'message si:message)))
+ (batch-update-autoloads))))
+
+(defun dgnushack-make-load ()
+ (unless (featurep 'xemacs)
+ (message "Generating %s..." dgnushack-gnus-load-file)
+ (with-temp-file dgnushack-gnus-load-file
+ (insert-file-contents dgnushack-cus-load-file)
+ (delete-file dgnushack-cus-load-file)
+ (goto-char (point-min))
+ (search-forward ";;; Code:")
+ (forward-line)
+ (delete-region (point-min) (point))
+ (insert "\
+;;; gnus-load.el --- automatically extracted custom dependencies and autoload
+;;
+;;; Code:
+")
+ (goto-char (point-max))
+ (if (search-backward "custom-versions-load-alist" nil t)
+ (forward-line -1)
+ (forward-line -1)
+ (while (eq (char-after) ?\;)
+ (forward-line -1))
+ (forward-line))
+ (delete-region (point) (point-max))
+ (insert "\n")
+ ;; smiley-* are duplicated. Remove them all.
+ (let ((point (point)))
+ (insert-file-contents dgnushack-gnus-load-file)
+ (goto-char point)
+ (while (search-forward "smiley-" nil t)
+ (beginning-of-line)
+ (if (looking-at "(autoload ")
+ (delete-region (point) (progn (forward-sexp) (point)))
+ (forward-line))))
+ ;;
+ (goto-char (point-max))
+ (when (search-backward "\n(provide " nil t)
+ (forward-line -1)
+ (delete-region (point) (point-max)))
+ (insert "\
+
+\(provide 'gnus-load)
+
+;;; Local Variables:
+;;; version-control: never
+;;; no-byte-compile: t
+;;; no-update-autoloads: t
+;;; End:
+;;; gnus-load.el ends here
+")
+ ))
+ (message "Compiling %s..." dgnushack-gnus-load-file)
+ (byte-compile-file dgnushack-gnus-load-file)
+ (when (featurep 'xemacs)
+ (message "Creating dummy gnus-load.el...")
+ (with-temp-file (expand-file-name "gnus-load.el")
+ (insert "\
+
+\(provide 'gnus-load)
+
+;;; Local Variables:
+;;; version-control: never
+;;; no-byte-compile: t
+;;; no-update-autoloads: t
+;;; End:
+;;; gnus-load.el ends here"))))
+
+\f
+(defconst dgnushack-info-file-regexp-en
+ (let ((names '("gnus" "message" "emacs-mime"))
+ regexp name)
+ (while (setq name (pop names))
+ (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
+ (when names "\\|"))))
+ regexp)
+ "Regexp matching English info files.")
+
+(defconst dgnushack-info-file-regexp-ja
+ (let ((names '("gnus-ja" "message-ja"))
+ regexp name)
+ (while (setq name (pop names))
+ (setq regexp (concat regexp "^" name "\\.info\\(-[0-9]+\\)?$"
+ (when names "\\|"))))
+ regexp)
+ "Regexp matching Japanese info files.")
+
+(defun dgnushack-remove-extra-files-in-package ()
+ "Remove extra files in the lisp directory of the XEmacs package."
+ (let ((lisp-dir (expand-file-name (concat "lisp/"
+ ;; GNUS_PRODUCT_NAME
+ (cadr command-line-args-left)
+ "/")
+ ;; PACKAGEDIR
+ (car command-line-args-left))))
+ (setq command-line-args-left nil)
+ (when (file-directory-p lisp-dir)
+ (let (files)
+ (dolist (file dgnushack-exporting-files)
+ (setq files (nconc files (list file (concat file "c")))))
+ (dolist (file (directory-files lisp-dir nil nil t t))
+ (unless (member file files)
+ (setq file (expand-file-name file lisp-dir))
+ (message "Removing %s..." file)
+ (condition-case nil
+ (delete-file file)
+ (error nil))))))))
+
+(defun dgnushack-install-package-manifest ()
+ "Install MANIFEST file as an XEmacs package."
+ (let* ((package-dir (pop command-line-args-left))
+ (product-name (pop command-line-args-left))
+ (pkginfo-dir (expand-file-name "pkginfo" package-dir))
+ (name (expand-file-name (concat "MANIFEST." product-name)
+ pkginfo-dir))
+ make-backup-files)
+ (unless (file-directory-p pkginfo-dir)
+ (message "Creating directory %s/..." pkginfo-dir)
+ (make-directory pkginfo-dir))
+ (message "Generating %s..." name)
+ (with-temp-file name
+ (insert "pkginfo/MANIFEST." product-name "\n")
+ (let ((lisp-dir (concat "lisp/" product-name "/"))
+ (files (sort (directory-files "." nil "\\.elc?$" t) 'string-lessp))
+ file)
+ (while (setq file (pop files))
+ (unless (member file dgnushack-unexporting-files)
+ (insert lisp-dir file "\n")))
+ (setq files
+ (sort (directory-files "../texi/" nil
+ (concat dgnushack-info-file-regexp-en
+ "\\|"
+ dgnushack-info-file-regexp-ja)
+ t)
+ 'string-lessp))
+ (while (setq file (pop files))
+ (insert "info/" file "\n"))
+ (insert "etc/gnus-tut.txt\n")
+ (setq files
+ (sort (directory-files "../etc/images/gnus/" nil
+ "\\.\\(pbm\\|xbm\\|xpm\\)\\'"
+ t)
+ 'string-lessp))
+ (while (setq file (pop files))
+ (insert "etc/images/gnus/" file "\n"))
+ (insert "etc/images/gnus/x-splash\n")
+ (setq files
+ (sort (directory-files "../etc/images/smilies/" nil
+ "\\.\\(pbm\\|xpm\\)\\'"
+ t)
+ 'string-lessp))
+ (while (setq file (pop files))
+ (insert "etc/images/smilies/" file "\n"))))))
+
+(defun dgnushack-find-lisp-shadows (&optional lispdir)
+ "Return a list of directories in which other Gnus installations exist.
+This function looks for the other Gnus installations which will shadow
+the new Gnus Lisp modules which have been installed in LISPDIR, using
+the default `load-path'. The return value will make sense only when
+LISPDIR is existent and is listed in the default `load-path'. Assume
+LISPDIR will be prepended to `load-path' by a user if the default
+`load-path' does not contain it."
+ (unless lispdir
+ (setq lispdir (getenv "lispdir")))
+ (when (and lispdir (file-directory-p lispdir))
+ (setq lispdir (file-truename (directory-file-name lispdir)))
+ (let ((indices '("gnus.elc" "gnus.el" "gnus.el.bz2" "gnus.el.gz"
+ "message.elc" "message.el" "message.el.bz2"
+ "message.el.gz"))
+ (path (delq nil (mapcar
+ (lambda (p)
+ (condition-case nil
+ (when (and p (file-directory-p p))
+ (file-truename (directory-file-name p)))
+ (error nil)))
+ dgnushack-default-load-path)))
+ rest elcs)
+ (while path
+ (setq rest (cons (car path) rest)
+ path (delete (car rest) (cdr path))))
+ (setq path (nreverse (cdr (member lispdir rest)))
+ rest nil)
+ (while path
+ (setq elcs indices)
+ (while elcs
+ (when (file-exists-p (expand-file-name (pop elcs) (car path)))
+ (setq rest (cons (car path) rest)
+ elcs nil)))
+ (setq path (cdr path)))
+ (prog1
+ (setq path (nreverse rest))
+ (when path
+ (let (print-level print-length)
+ (princ (concat "\n\
+WARNING: The other gnus installation" (if (cdr path) "s have" " has") "\
+ been detected in:\n\n " (mapconcat 'identity path "\n ") "\n\n\
+You will need to modify the run-time `load-path', remove them manually,
+or remove them using `make remove-installed-shadows'.\n\n"))))))))
+
+(defun dgnushack-remove-lisp-shadows (&optional lispdir)
+ "Remove the other Gnus installations which shadow the recent one."
+ (let ((path (with-temp-buffer
+ (let ((standard-output (current-buffer)))
+ (dgnushack-find-lisp-shadows lispdir))))
+ elcs files shadows file)
+ (when path
+ (unless (setq elcs (directory-files srcdir nil "\\.elc\\'"))
+ (error "You should build .elc files first."))
+ (setq files
+ (apply
+ 'append
+ (mapcar
+ (lambda (el)
+ (list (concat el "c") el (concat el ".bz2") (concat el ".gz")))
+ (append
+ (list (file-name-nondirectory dgnushack-gnus-load-file)
+ (file-name-nondirectory dgnushack-cus-load-file))
+ (mapcar (lambda (elc) (substring elc 0 -1)) elcs)))))
+ (while path
+ (setq shadows files)
+ (while shadows
+ (setq file (expand-file-name (pop shadows) (car path)))
+ (when (file-exists-p file)
+ (princ (concat " Removing " file "..."))
+ (condition-case nil
+ (progn
+ (delete-file file)
+ (princ "done\n"))
+ (error (princ "failed\n")))))
+ (setq path (cdr path))))))
+
+;;; dgnushack.el ends here