+;;; @ detect install path
+;;;
+
+;; install to shared directory (maybe "/usr/local")
+(defvar install-prefix
+ (if (or running-emacs-18 running-xemacs
+ (and (boundp 'system-configuration-options) ; 19.29 or later
+ (string= system-configuration-options "NT"))) ; for Meadow
+ (expand-file-name "../../.." exec-directory)
+ (expand-file-name "../../../.." data-directory)))
+
+(defvar install-elisp-prefix
+ (if (>= emacs-major-version 19)
+ "site-lisp"
+ "local.lisp"))
+
+(defun install-detect-elisp-directory (&optional prefix elisp-prefix
+ allow-version-specific)
+ (or prefix
+ (setq prefix install-prefix)
+ )
+ (or elisp-prefix
+ (setq elisp-prefix install-elisp-prefix)
+ )
+ (or
+ (catch 'tag
+ (let ((rest default-load-path)
+ (pat (concat "^"
+ (expand-file-name (concat ".*/" elisp-prefix) prefix)
+ "/?$"))
+ dir)
+ (while (setq dir (car rest))
+ (if (string-match pat dir)
+ (if (or allow-version-specific
+ (not (string-match (format "/%d\\.%d"
+ emacs-major-version
+ emacs-minor-version) dir))
+ )
+ (throw 'tag dir)
+ ))
+ (setq rest (cdr rest))
+ )))
+ (expand-file-name (concat
+ (if running-emacs-19_29-or-later
+ "share/"
+ "lib/")
+ (cond ((boundp 'NEMACS) "nemacs/")
+ ((boundp 'MULE) "mule/")
+ (running-xemacs
+ (if (featurep 'mule)
+ "xmule/"
+ "xemacs/"))
+ (t "emacs/"))
+ elisp-prefix) prefix)
+ ))
+
+(defvar install-default-elisp-directory
+ (install-detect-elisp-directory))
+
+