1 ;;;; $Id: hyperspec-lookup.lisp,v 1.1 2003-11-13 19:12:22 eenge Exp $
2 ;;;; $Source: /home/david/clbuild/source/hyperspec-lookup.cvsroot/cvsroot/hyperspec-lookup/hyperspec-lookup.lisp,v $
4 ;;;; See the LICENSE file for licensing information.
8 (defvar *hyperdoc-base-uri
* t
) ;; KLUDGE
10 (defun hyperdoc-lookup (base symbol type
)
11 (declare (ignore base type
))
12 (lookup (symbol-name symbol
)))
14 (defun read-sym-file (&optional
(pathname *hyperspec-map-file
*))
15 "Read the sym file and return it as an alist."
17 (with-open-file (stream pathname
:direction
:input
)
18 (do ((symbol-name (read-line stream nil
) (read-line stream nil
))
19 (symbol-url (read-line stream nil
) (read-line stream nil
)))
20 ((eq symbol-name nil
) nil
)
21 (let ((symbol-url (if (string-equal (subseq symbol-url
0 2) "..")
24 (setf alist
(acons symbol-name symbol-url alist
)))))
27 (defun populate-table (alist &optional
(table *hyperspec-table
*))
28 "Populate table with information from alist (as created by
30 (dolist (symbol-pair alist
)
31 (let ((symbol-name (car symbol-pair
))
32 (symbol-url (cdr symbol-pair
)))
33 (setf (gethash symbol-name table
) symbol-url
)))
36 ;; initializes the tables with default data
37 (populate-table (read-sym-file))
38 (populate-table (read-sym-file *mop-map-file
*) *mop-table
*)
40 (defun symbol-url-lookup (symbol url-root table
)
41 "Look up symbol in table and if it exist concatenate it with
42 url-root and return that."
43 (let ((url (gethash symbol table
)))
45 (concatenate 'string url-root url
))))
47 (defun hyperspec-lookup (symbol &optional
(root *hyperspec-root
*)
48 (table *hyperspec-table
*))
49 "Look up symbol in the Hyperspec; will return the URL to the symbol
50 or nil if it could not be found."
51 (symbol-url-lookup symbol root table
))
53 (defun mop-lookup (symbol &optional
(root *mop-root
*)
55 "Look up symbol in the MOP; will return the URL to the symbol or
56 nil if it could not be found."
57 (symbol-url-lookup symbol root table
))
59 (defun lookup (symbol)
60 "Look up symbol in the Hyperspec, then MOP."
61 (or (hyperspec-lookup symbol
)