+(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)
+ (progn
+ (if (file-exists-p generated-autoload-file)
+ (delete-file generated-autoload-file))
+ (if (file-exists-p dgnushack-auto-load-file)
+ (delete-file dgnushack-auto-load-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 ()
+ (message "Generating %s..." dgnushack-gnus-load-file)
+ (with-temp-file dgnushack-gnus-load-file
+ (if (file-exists-p dgnushack-cus-load-file)
+ (progn
+ (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))
+ (unless (re-search-forward "\
+^[\t ]*(autoload[\t\n ]+\\('\\|(quote[\t\n ]+\\)custom-add-loads[\t\n ]"
+ nil t)
+ (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))
+ (goto-char (point-min))
+ (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"))
+ (insert "\
+;;; gnus-load.el --- automatically extracted autoload
+;;
+;;; Code:
+"))
+ ;; 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
+")
+ ;; Workaround the bug in some version of XEmacs.
+ (when (featurep 'xemacs)
+ (condition-case nil
+ (require 'cus-load)
+ (error nil))
+ (goto-char (point-min))
+ (when (and (fboundp 'custom-add-loads)
+ (not (search-forward "\n(autoload 'custom-add-loads " nil t)))
+ (search-forward "\n;;; Code:" nil t)
+ (forward-line 1)
+ (insert "\n(autoload 'custom-add-loads \"cus-load\")\n"))))
+ (message "Compiling %s..." dgnushack-gnus-load-file)
+ (byte-compile-file dgnushack-gnus-load-file))
+
+\f
+(defun dgnushack-compose-package ()
+ "Re-split the file gnus-load.el into custom-load.el and
+auto-autoloads.el. It is silly, should be improved!"
+ (message "
+Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...")
+ (let ((customload (expand-file-name "custom-load.el" srcdir))
+ (autoloads (expand-file-name "auto-autoloads.el" srcdir))
+ start)
+ (with-temp-buffer
+ (insert-file-contents dgnushack-gnus-load-file)
+ (delete-file dgnushack-gnus-load-file)
+ (when (file-exists-p (concat dgnushack-gnus-load-file "c"))
+ (delete-file (concat dgnushack-gnus-load-file "c")))
+ (while (prog1
+ (looking-at "[\t ;]")
+ (forward-line 1)))
+ (setq start (point))
+ (insert "\
+;;; custom-load.el --- automatically extracted custom dependencies\n
+;;; Code:\n\n")
+ (goto-char (point-max))
+ (while (progn
+ (forward-line -1)
+ (not (looking-at "[\t ]*(custom-add-loads[\t\n ]"))))
+ (forward-list 1)
+ (forward-line 1)
+ (insert "\n;;; custom-load.el ends here\n")
+ (write-region start (point) customload)
+ (while (looking-at "[\t ]*$")
+ (forward-line 1))
+ (setq start (point))
+ (if (re-search-forward "^[\t\n ]*(if[\t\n ]+(featurep[\t\n ]" nil t)
+ (let ((from (goto-char (match-beginning 0))))
+ (delete-region from (progn
+ (forward-list 1)
+ (forward-line 1)
+ (point))))
+ (while (looking-at "[\t ;]")
+ (forward-line 1)))
+ (insert "(if (featurep 'gnus-autoloads) (error \"Already loaded\"))\n")
+ (goto-char (point-max))
+ (while (progn
+ (forward-line -1)
+ (not (looking-at "[\t ]*(provide[\t\n ]"))))
+ (insert "(provide 'gnus-autoloads)\n")
+ (write-region start (point) autoloads))
+ (byte-compile-file customload)
+ (byte-compile-file autoloads))
+ (message "\
+Re-splitting gnus-load.el into custom-load.el and auto-autoloads.el...done
+\n"))
+
+\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"))))))
+
+\f
+(define-compiler-macro describe-key-briefly (&whole form key &optional insert)
+ (if (condition-case nil
+ (progn
+ (describe-key-briefly '((())) nil)
+ t)
+ (wrong-number-of-arguments nil);; Old Emacsen.
+ (error t))
+ form
+ (if insert
+ `(if ,insert
+ (insert (funcall 'describe-key-briefly ,key))
+ (funcall 'describe-key-briefly ,key))
+ `(funcall 'describe-key-briefly ,key))))
+
+;;; dgnushack.el ends here