;;; hversion.el --- Hyperbole version, system and load path information.;; Copyright (C) 1994, 1995, 2004, 2005, 2006, 2007, 2008 Free;; Software Foundation, Inc. Developed with support from Motorola;; Inc.;; Author: Bob Weiner, Brown U.;; Maintainer: Mats Lidell <matsl@contactor.se>;; Keywords: hypermedia;; This file is part of GNU Hyperbole.;; GNU Hyperbole is free software; you can redistribute it and/or;; modify it under the terms of the GNU General Public License as;; published by the Free Software Foundation; either version 3, or (at;; your option) any later version.;; GNU Hyperbole is distributed in the hope that it will be useful,;; but WITHOUT ANY WARRANTY; without even the implied warranty of;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU;; General Public License for more details.;; You should have received a copy of the GNU General Public License;; along with GNU Emacs; see the file COPYING. If not, write to the;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,;; Boston, MA 02110-1301, USA.;;; Commentary:;;; Code:;;;;;; Public variables;;;(defconsthyperb:version"5.0.3""Hyperbole revision number.");;; Support button highlighting and flashing under XEmacs.;;;(defvarhyperb:xemacs-p(let((case-fold-searcht))(if(string-match"XEmacs"emacs-version)emacs-version))"Version string under XEmacs (not Lucid Emacs) or nil");;; Support mouse handling under GNU Emacs V19 and beyond.;;;(defvarhyperb:emacs19-p(and(nothyperb:xemacs-p)(string-match"^\\(19\\|2[0-9]\\)\\."emacs-version)emacs-version)"Version string under GNU Emacs 19 or nil");;; Support button highlighting and flashing under obsolete Epoch.;;;(defvarhyperb:epoch-p(if(and(boundp'epoch::version)(stringpepoch::version))(if(string<epoch::version"Epoch 4")"V3""V4"))"Simplified version string under Epoch, e.g. \"V4\", or nil");; Koutlines work only with specific versions of Emacs 19 and XEmacs.(defconsthyperb:kotl-p(ifhyperb:xemacs-p;; Only works for XEmacs 19.9 and above.(emacs-version>=199)hyperb:emacs19-p)"Non-nil iff this Emacs version supports the Hyperbole outliner.");; Used by OO-Browser (Deprecated!?)(defconsthyperb:microcruft-os-p(memqsystem-type'(windows-ntms-dos))"T iff Hyperbole is running under Windows or DOS.")(defunsm-window-sys-term()"Returns the first part of the term-type if running under a window system, else nil.Where a part in the term-type is delimited by a '-' or an '_'."(let((term(cond((memqwindow-system'(xgtknsdpspmmswindows));; X11, NEXTSTEP (DPS), or OS/2 Presentation Manager (PM)(cond(hyperb:emacs19-p"emacs19")(hyperb:xemacs-p"xemacs")(hyperb:epoch-p"epoch")(t"xterm")))((or(featurep'eterm-fns)(equal(getenv"TERM")"NeXT")(equal(getenv"TERM")"eterm"));; NEXTSTEP add-on support to Emacs"next")((orwindow-system(featurep'sun-mouse)(featurep'apollo))(getenv"TERM")))))(andterm(substringterm0(string-match"[-_]"term)))))(defconsthyperb:window-system(sm-window-sys-term)"String name for window system or term type under which Emacs was run.If nil, no window system or mouse support is available.");;;;;; Public functions to dynamically compute Hyperbole directory.;;;(defvarhyperb:automount-prefixes(if(and(boundp'automount-dir-prefix)(stringpautomount-dir-prefix))automount-dir-prefix"^/tmp_mnt/""*Regexp to match any automounter prefix in a pathname."))(defunhyperb:stack-frame(function-list&optionaldebug-flag)"Return the nearest Emacs Lisp stack frame which called any function symbol from FUNCTION-LIST or nil if no match.If FUNCTION-LIST contains 'load, 'autoload or 'require, detectautoloads not visible within the Lisp level stack frames.With optional DEBUG-FLAG non-nil, if no matching frame is found, return listof stack frames (from innermost to outermost)."(let((count0)(frame-list)(load-flag(or(memq'loadfunction-list)(memq'autoloadfunction-list)(memq'requirefunction-list)))fsymbolfbodyframe)(or(catch'hyperb:stack-frame(while(setqframe(backtrace-framecount))(ifdebug-flag(setqframe-list(consframeframe-list)))(setqcount(1+count)fsymbol(nth1frame))(and(eqfsymbol'command-execute)(not(memq'command-executefunction-list));; Use command being executed instead because it might not;; show up in the stack anywhere else, e.g. if it is an;; autoload under Emacs 19.(setqfsymbol(nth2frame)))(cond((andload-flag(symbolpfsymbol)(fboundpfsymbol)(listp(setqfbody(symbol-functionfsymbol)))(eq(carfbody)'autoload))(setqframe(list(carframe)'load(car(cdrfbody))nilnoninteractivenil))(throw'hyperb:stack-frameframe))((memqfsymbolfunction-list)(throw'hyperb:stack-frameframe))))nil)(ifdebug-flag(nreverseframe-list)))))(defunhyperb:path-being-loaded()"Return the full pathname used by the innermost `load' or 'require' call.Removes any matches for `hyperb:automount-prefixes' before returningthe pathname."(let*((frame(hyperb:stack-frame'(loadrequire)))(function(nth1frame))filenosuffix)(cond((eqfunction'load)(setqfile(nth2frame)nosuffix(nth5frame)))((eqfunction'require)(setqfile(or(nth3frame)(symbol-name(nth2frame))))))(if(stringpfile)(setqnosuffix(ornosuffix(string-match"\\.\\(elc?\\|elc?\\.gz\\|elc?\\.Z\\)$"file))file(substitute-in-file-namefile)file(locate-filefileload-path(if(nullnosuffix)'(".elc"".el"".el.gz"".el.Z"));; accept any existing filenil)file(if(and(stringpfile)(string-matchhyperb:automount-prefixesfile))(substringfile(1-(match-end0)))file)))))(if(fboundp'locate-file)nil(defunlocate-file(filedir-list&optionalsuffixesunused)"Search for FILE in DIR-LIST.If optional SUFFIXES is provided, it should be a list of suffixes to append to file name when searching."(if(and(file-name-absolute-pfile)(file-readable-pfile))file;; file exists without suffix addition, so return it(if(file-name-absolute-pfile)(setqdir-list'(nil)))(if(equalfile"")(error"(locate-file): Empty file argument"))(let(suffxspathname);; Search dir-list for a matching, readable file.(catch'found(whiledir-list(setqsuffxs(orsuffixes'(nil)))(whilesuffxs(setqpathname(expand-file-name(concatfile(carsuffxs))(cardir-list)))(if(file-readable-ppathname)(throw'foundpathname))(setqsuffxs(cdrsuffxs)))(setqdir-list(cdrdir-list))))))));;;;;; Public functions used by pulldown and popup menus;;;(if(not(fboundp'id-browse-file))(fset'id-browse-file'find-file-read-only))(if(not(fboundp'id-info))(defunid-info(node)(if(br-in-browser)(br-to-view-window))(Info-goto-nodenode)))(if(not(fboundp'id-tool-quit))(fset'id-tool-quit'eval))(if(not(fboundp'id-tool-invoke))(defunid-tool-invoke(sexp)(if(commandpsexp)(call-interactivelysexp)(funcallsexp))))(provide'hversion);;; hversion.el ends here