0
|
1 ;;!emacs
|
|
2 ;;
|
36
|
3 ;; LCD-ENTRY: hyperbole|Bob Weiner|hyperbole@infodock.com|Everyday Info Manager|17-Mar-97|4.023|ftp://ftp.xemacs.org/pub/infodock
|
0
|
4 ;;
|
|
5 ;; FILE: hversion.el
|
|
6 ;; SUMMARY: Hyperbole version, system and load path information.
|
|
7 ;; USAGE: GNU Emacs Lisp Library
|
|
8 ;; KEYWORDS: hypermedia
|
|
9 ;;
|
|
10 ;; AUTHOR: Bob Weiner
|
24
|
11 ;; ORG: InfoDock Associates
|
0
|
12 ;;
|
|
13 ;; ORIG-DATE: 1-Jan-94
|
36
|
14 ;; LAST-MOD: 17-Mar-97 at 21:08:15 by Bob Weiner
|
0
|
15 ;;
|
|
16 ;; This file is part of Hyperbole.
|
|
17 ;; Available for use and distribution under the same terms as GNU Emacs.
|
|
18 ;;
|
24
|
19 ;; Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
|
0
|
20 ;; Developed with support from Motorola Inc.
|
|
21 ;;
|
|
22 ;; DESCRIPTION:
|
|
23 ;; DESCRIP-END.
|
|
24
|
|
25 ;;; ************************************************************************
|
|
26 ;;; Public variables
|
|
27 ;;; ************************************************************************
|
|
28
|
36
|
29 (defconst hyperb:version "04.023" "Hyperbole revision number.")
|
0
|
30
|
|
31 ;;; Support button highlighting and flashing under XEmacs.
|
|
32 ;;;
|
|
33 (defvar hyperb:xemacs-p
|
|
34 (let ((case-fold-search t))
|
|
35 (if (string-match "XEmacs" emacs-version)
|
|
36 emacs-version))
|
|
37 "Version string under XEmacs (not Lucid Emacs) or nil")
|
|
38
|
|
39 ;;; Support button highlighting and flashing under obsolete Lucid Emacs.
|
|
40 ;;;
|
|
41 (defvar hyperb:lemacs-p
|
|
42 (let ((case-fold-search t))
|
|
43 (if (string-match "XEmacs\\|Lucid" emacs-version)
|
|
44 emacs-version))
|
|
45 "Version string under XEmacs or Lucid Emacs or nil")
|
|
46
|
|
47 ;;; Support mouse handling under GNU Emacs V19.
|
|
48 ;;;
|
|
49 (defvar hyperb:emacs19-p
|
|
50 (and (not hyperb:lemacs-p)
|
|
51 (string-match "^19\\." emacs-version)
|
|
52 emacs-version)
|
|
53 "Version string under GNU Emacs 19 or nil")
|
|
54
|
|
55 ;;; Support button highlighting and flashing under obsolete Epoch.
|
|
56 ;;;
|
|
57 (defvar hyperb:epoch-p
|
|
58 (if (and (boundp 'epoch::version)
|
|
59 (stringp epoch::version))
|
|
60 (if (string< epoch::version "Epoch 4") "V3" "V4"))
|
|
61 "Simplified version string under Epoch, e.g. \"V4\", or nil")
|
|
62
|
24
|
63 ;;; Koutlines work only with specific versions of Emacs 19 and XEmacs.
|
0
|
64 (defconst hyperb:kotl-p
|
|
65 (if hyperb:lemacs-p
|
|
66 ;; Only works for XEmacs 19.9 and above.
|
24
|
67 (or (string-match "^19\\.9 \\|^19\\.[1-9][0-9]" emacs-version)
|
|
68 ;; Version 20 and above.
|
|
69 (string-lessp "20" emacs-version))
|
0
|
70 hyperb:emacs19-p)
|
|
71 "Non-nil iff this Emacs version supports the Hyperbole outliner.")
|
|
72
|
24
|
73 ;;; Account for what rain all year round and working for two ex-Harvard guys
|
|
74 ;;; will do to programmers.
|
|
75 (defvar hyperb:microcruft-os-p
|
|
76 (memq system-type '(ms-windows windows-nt ms-dos))
|
|
77 "T iff Hyperbole is running under a Microcruft OS.")
|
|
78
|
0
|
79 (defun sm-window-sys-term ()
|
|
80 "Returns the first part of the term-type if running under a window system, else nil.
|
|
81 Where a part in the term-type is delimited by a '-' or an '_'."
|
24
|
82 (let* ((display-type (if (fboundp 'device-type) (device-type) window-system))
|
|
83 (term (cond ((memq display-type '(x ns dps pm win32))
|
|
84 ;; X11, NEXTSTEP (DPS), or OS/2 Presentation Manager (PM)
|
|
85 (cond (hyperb:emacs19-p "emacs19")
|
|
86 (hyperb:lemacs-p "lemacs")
|
|
87 (hyperb:epoch-p "epoch")
|
|
88 (t "xterm")))
|
|
89 ((or (featurep 'eterm-fns)
|
|
90 (equal (getenv "TERM") "NeXT")
|
|
91 (equal (getenv "TERM") "eterm"))
|
|
92 ;; NEXTSTEP add-on support to Emacs
|
|
93 "next")
|
|
94 ((or display-type
|
|
95 (featurep 'sun-mouse) (featurep 'apollo))
|
|
96 (getenv "TERM")))))
|
0
|
97 (and term
|
|
98 (substring term 0 (string-match "[-_]" term)))))
|
|
99
|
|
100 (defconst hyperb:window-system (sm-window-sys-term)
|
|
101 "String name for window system or term type under which Emacs was run.
|
|
102 If nil, no window system or mouse support is available.")
|
|
103
|
|
104 ;;; ************************************************************************
|
|
105 ;;; Public functions to dynamically compute Hyperbole directory.
|
|
106 ;;; ************************************************************************
|
|
107
|
|
108 (defvar hyperb:automount-prefixes
|
|
109 (if (and (boundp 'automount-dir-prefix) (stringp automount-dir-prefix))
|
|
110 automount-dir-prefix
|
|
111 "^/tmp_mnt/"
|
|
112 "*Regexp to match any automounter prefix in a pathname."))
|
|
113
|
|
114 (defun hyperb:stack-frame (function-list &optional debug-flag)
|
|
115 "Return the nearest Emacs Lisp stack frame which called any function symbol from FUNCTION-LIST or nil if no match.
|
|
116 If FUNCTION-LIST contains 'load, 'autoload or 'require, detect
|
|
117 autoloads not visible within the Lisp level stack frames.
|
|
118
|
|
119 With optional DEBUG-FLAG non-nil, if no matching frame is found, return list
|
|
120 of stack frames (from innermost to outermost)."
|
|
121 (let ((count 0)
|
|
122 (frame-list)
|
|
123 (load-flag (or (memq 'load function-list)
|
|
124 (memq 'autoload function-list)
|
|
125 (memq 'require function-list)))
|
|
126 fsymbol
|
|
127 fbody
|
|
128 frame)
|
|
129 (or (catch 'hyperb:stack-frame
|
|
130 (while (setq frame (backtrace-frame count))
|
|
131 (if debug-flag (setq frame-list (cons frame frame-list)))
|
|
132 (setq count (1+ count)
|
|
133 fsymbol (nth 1 frame))
|
|
134 (and (eq fsymbol 'command-execute)
|
|
135 (not (memq 'command-execute function-list))
|
|
136 ;; Use command being executed instead because it might not
|
|
137 ;; show up in the stack anywhere else, e.g. if it is an
|
|
138 ;; autoload under Emacs 19.
|
|
139 (setq fsymbol (nth 2 frame)))
|
|
140 (cond ((and load-flag (symbolp fsymbol)
|
|
141 (fboundp fsymbol)
|
|
142 (listp (setq fbody (symbol-function fsymbol)))
|
|
143 (eq (car fbody) 'autoload))
|
|
144 (setq frame (list (car frame) 'load
|
|
145 (car (cdr fbody))
|
|
146 nil noninteractive nil))
|
|
147 (throw 'hyperb:stack-frame frame))
|
|
148 ((memq fsymbol function-list)
|
|
149 (throw 'hyperb:stack-frame frame))))
|
|
150 nil)
|
|
151 (if debug-flag (nreverse frame-list)))))
|
|
152
|
|
153 (defun hyperb:path-being-loaded ()
|
|
154 "Return the full pathname used by the innermost `load' or 'require' call.
|
|
155 Removes any matches for `hyperb:automount-prefixes' before returning
|
|
156 the pathname."
|
|
157 (let* ((frame (hyperb:stack-frame '(load require)))
|
|
158 (function (nth 1 frame))
|
|
159 file nosuffix)
|
|
160 (cond ((eq function 'load)
|
|
161 (setq file (nth 2 frame)
|
|
162 nosuffix (nth 5 frame)))
|
|
163 ((eq function 'require)
|
|
164 (setq file (or (nth 3 frame) (symbol-name (nth 2 frame))))))
|
|
165 (if (stringp file)
|
|
166 (setq nosuffix (or nosuffix
|
|
167 (string-match
|
|
168 "\\.\\(elc?\\|elc?\\.gz\\|elc?\\.Z\\)$"
|
|
169 file))
|
|
170 file (substitute-in-file-name file)
|
|
171 file (locate-file file load-path
|
|
172 (if nosuffix "" ".elc:.el:.el.gz:.el.Z:")
|
|
173 ;; accept any existing file
|
|
174 0)
|
|
175 file (if (and (stringp file)
|
|
176 (string-match hyperb:automount-prefixes file))
|
|
177 (substring file (1- (match-end 0)))
|
|
178 file)))))
|
|
179
|
|
180 (if (fboundp 'locate-file)
|
|
181 nil
|
|
182 (defun locate-file (file dir-list &optional suffix-string unused)
|
|
183 "Search for FILE in DIR-LIST.
|
|
184 If optional SUFFIX-STRING is provided, allow file to be followed by one of the
|
|
185 colon separated suffixes."
|
|
186 (let ((suffix-list))
|
|
187 (cond ((null suffix-string) (setq suffix-list '("")))
|
|
188 ((stringp suffix-string)
|
|
189 (let ((start 0)
|
|
190 (len (length suffix-string)))
|
|
191 (while (and (< start len)
|
|
192 (string-match "[^:]+" suffix-string start))
|
|
193 (setq suffix-list
|
|
194 (cons (substring suffix-string
|
|
195 (match-beginning 0)
|
|
196 (match-end 0))
|
|
197 suffix-list)
|
|
198 start (1+ (match-end 0))))
|
|
199 (setq suffix-list (nconc (nreverse suffix-list) '("")))))
|
|
200 (t (error "(locate-file): Invalid third arg, '%s', use a colon separated string of file suffixes"
|
|
201 suffix-string)))
|
|
202 (if (and (file-name-absolute-p file) (file-readable-p file))
|
|
203 file;; file exists without suffix addition, so return it
|
|
204 (if (file-name-absolute-p file) (setq dir-list '(nil)))
|
|
205 (if (equal file "") (error "(locate-file): Empty file argument"))
|
|
206 (let (suffixes pathname)
|
|
207 ;; Search dir-list for a matching, readable file.
|
|
208 (catch 'found
|
|
209 (while dir-list
|
|
210 (setq suffixes suffix-list)
|
|
211 (while suffixes
|
|
212 (setq pathname (expand-file-name
|
|
213 (concat file (car suffixes))
|
|
214 (car dir-list)))
|
|
215 (if (file-readable-p pathname)
|
|
216 (throw 'found pathname))
|
|
217 (setq suffixes (cdr suffixes)))
|
|
218 (setq dir-list (cdr dir-list)))))))))
|
|
219
|
|
220 ;;; ************************************************************************
|
|
221 ;;; Public functions used by pulldown and popup menus
|
|
222 ;;; ************************************************************************
|
|
223
|
|
224 (if (not (fboundp 'id-browse-file))
|
|
225 (fset 'id-browse-file 'find-file-read-only))
|
|
226
|
|
227 (if (not (fboundp 'id-info))
|
|
228 (defun id-info (node)
|
|
229 (if (br-in-browser) (br-to-view-window))
|
|
230 (Info-goto-node node)))
|
|
231
|
|
232 (if (not (fboundp 'id-tool-quit)) (fset 'id-tool-quit 'eval))
|
|
233
|
|
234 (if (not (fboundp 'id-tool-invoke))
|
|
235 (defun id-tool-invoke (sexp)
|
|
236 (if (commandp sexp)
|
|
237 (call-interactively sexp)
|
|
238 (funcall sexp))))
|
|
239
|
|
240 (provide 'hversion)
|