+;; To avoid having defsubsts and inlines happen.
+;(if (featurep 'xemacs)
+; (require 'byte-optimize)
+; (require 'byte-opt))
+;(defun byte-optimize-inline-handler (form)
+; "byte-optimize-handler for the `inline' special-form."
+; (cons 'progn (cdr form)))
+;(defalias 'byte-compile-file-form-defsubst 'byte-compile-file-form-defun)
+
+(when (and (not (featurep 'xemacs))
+ (= emacs-major-version 21)
+ (= emacs-minor-version 3)
+ (condition-case code
+ (let ((byte-compile-error-on-warn t))
+ (byte-optimize-form (quote (pop x)) t)
+ nil)
+ (error (string-match "called for effect"
+ (error-message-string code)))))
+ (defadvice byte-optimize-form-code-walker (around silence-warn-for-pop
+ (form for-effect)
+ activate)
+ "Silence the warning \"...called for effect\" for the `pop' form.
+It is effective only when the `pop' macro is defined by cl.el rather
+than subr.el."
+ (let (tmp)
+ (if (and (eq (car-safe form) 'car)
+ for-effect
+ (setq tmp (get 'car 'side-effect-free))
+ (not byte-compile-delete-errors)
+ (not (eq tmp 'error-free))
+ (eq (car-safe (cadr form)) 'prog1)
+ (let ((var (cadr (cadr form)))
+ (last (nth 2 (cadr form))))
+ (and (symbolp var)
+ (null (nthcdr 3 (cadr form)))
+ (eq (car-safe last) 'setq)
+ (eq (cadr last) var)
+ (eq (car-safe (nth 2 last)) 'cdr)
+ (eq (cadr (nth 2 last)) var))))
+ (progn
+ (put 'car 'side-effect-free 'error-free)
+ (unwind-protect
+ ad-do-it
+ (put 'car 'side-effect-free tmp)))
+ ad-do-it))))
+
+(when (and (not (featurep 'xemacs))
+ (byte-optimize-form '(and (> 0 1) foo) t))
+ (defadvice byte-optimize-form-code-walker
+ (around fix-bug-in-and/or-forms (form for-effect) activate)
+ "Optimize the rest of the and/or forms.
+It has been fixed in XEmacs before releasing 21.4 and also has been
+fixed in Emacs after 21.3."
+ (if (and for-effect (memq (car-safe form) '(and or)))
+ (let ((fn (car form))
+ (backwards (reverse (cdr form))))
+ (while (and backwards
+ (null (setcar backwards
+ (byte-optimize-form (car backwards) t))))
+ (setq backwards (cdr backwards)))
+ (if (and (cdr form) (null backwards))
+ (byte-compile-log
+ " all subforms of %s called for effect; deleted" form))
+ (when backwards
+ (setcdr backwards
+ (mapcar 'byte-optimize-form (cdr backwards))))
+ (setq ad-return-value (cons fn (nreverse backwards))))
+ ad-do-it)))
+
+;; Add `early-package-load-path' to `load-path' for XEmacs. Those paths
+;; won't appear in `load-path' when XEmacs starts with the `-no-autoloads'
+;; option because of a bug. :<
+(when (and (featurep 'xemacs)
+ (string-match "--package-path=\\([^ ]+\\)"
+ system-configuration-options))
+ (let ((paths
+ (apply 'nconc
+ (mapcar
+ (lambda (path)
+ (when (file-directory-p
+ (setq path (expand-file-name "lisp" path)))
+ (directory-files path t)))
+ (split-string (match-string 1 system-configuration-options)
+ "::"))))
+ path adds)
+ (while paths
+ (setq path (car paths)
+ paths (cdr paths))
+ (when (and path
+ (not (or (string-match "/\\.\\.?\\'" path)
+ (member (file-name-as-directory path) load-path)
+ (member path load-path)))
+ (file-directory-p path))
+ (push (file-name-as-directory path) adds)))
+ (setq load-path (nconc (nreverse adds) load-path))))
+
+(if (file-exists-p (expand-file-name "dgnuspath.el" srcdir))
+ (load (expand-file-name "dgnuspath.el" srcdir) nil nil t)
+ (message " ** There's no dgnuspath.el file"))
+
+(condition-case err
+ (load "~/.lpath.el" t nil t)
+ (error (message "Error in \"~/.lpath.el\" file: %s" err)))
+
+;; Don't load path-util until `char-after' and `char-before' have been
+;; optimized because it requires `poe' and then modify the functions.
+
+;; If the APEL modules are installed under the non-standard directory,
+;; for example "/var/home/john/lisp/apel-VERSION/", you should add that
+;; name using the configure option "--with-addpath=".
+;; And also the directory where the EMU modules are installed, for
+;; example "/usr/local/share/mule/19.34/site-lisp/", it should be
+;; included in the standard `load-path' or added by the configure
+;; option "--with-addpath=".
+(let ((path (or (locate-library "path-util")
+ (locate-library "apel/path-util")));; backward compat.
+ parent lpath)
+ (if path
+ (progn
+ (when (string-match "/$" (setq path (file-name-directory path)))
+ (setq path (substring path 0 (match-beginning 0))))
+ ;; path == "/var/home/john/lisp/apel-VERSION"
+ (when (string-match "/$" (setq parent (file-name-directory path)))
+ (setq parent (substring path 0 (match-beginning 0))))
+ ;; parent == "/var/home/john/lisp"
+ (if (setq lpath (or (member path load-path)
+ (member (file-name-as-directory path) load-path)))
+ (unless (or (member parent load-path)
+ (member (file-name-as-directory parent) load-path))
+ (push parent (cdr lpath)))
+ (push path load-path)
+ (unless (or (member parent load-path)
+ (member (file-name-as-directory parent) load-path))
+ (push parent (cdr load-path))))
+ (require 'advice)
+ (require 'path-util))
+ (error "
+APEL modules are not found in %s.
+Try to re-configure with --with-addpath=APEL_PATH and run make again.
+"
+ load-path)))
+
+(unless (locate-library "mel")
+ (add-path "flim"))
+(unless (module-installed-p 'mel)
+ ;; FLIM 1.14 may have installed in two "flim" subdirectories.
+ (push (expand-file-name "flim"
+ (file-name-directory (get-latest-path "^apel$" t)))
+ load-path)
+ (unless (module-installed-p 'mel)
+ (error "
+FLIM modules does not found in %s.
+Try to re-configure with --with-addpath=FLIM_PATH and run make again.
+"
+ load-path)))
+(add-path "semi")
+
+(when (and (featurep 'xemacs)
+ (let ((table (copy-syntax-table emacs-lisp-mode-syntax-table)))
+ (modify-syntax-entry ?= " " table)
+ (with-temp-buffer
+ (with-syntax-table table
+ (insert "foo=bar")
+ (goto-char (point-min))
+ (forward-sexp 1)
+ (eolp)))))
+ ;; The original `with-syntax-table' uses `copy-syntax-table' which
+ ;; doesn't seem to copy modified syntax entries in XEmacs 21.5.
+ (defmacro with-syntax-table (syntab &rest body)
+ "Evaluate BODY with the SYNTAB as the current syntax table."
+ `(let ((stab (syntax-table)))
+ (unwind-protect
+ (progn
+ ;;(set-syntax-table (copy-syntax-table ,syntab))
+ (set-syntax-table ,syntab)
+ ,@body)
+ (set-syntax-table stab)))))
+
+(push srcdir load-path)
+(push loaddir load-path)
+(load (expand-file-name "lpath.el" loaddir) nil t)
+
+(require 'custom)
+
+;; Bind functions defined by `defun-maybe'.
+(put 'defun-maybe 'byte-hunk-handler 'byte-compile-file-form-defun-maybe)
+(defun byte-compile-file-form-defun-maybe (form)
+ (if (and (not (fboundp (nth 1 form)))
+ (memq 'unresolved byte-compile-warnings))
+ (setq byte-compile-function-environment
+ (cons (cons (nth 1 form)
+ (cons 'lambda (cdr (cdr form))))
+ byte-compile-function-environment)))
+ form)
+
+;; Unknown variables and functions.
+(unless (featurep 'xemacs)
+ (defalias 'Custom-make-dependencies 'ignore)
+ (defalias 'update-autoloads-from-directory 'ignore))