-
Notifications
You must be signed in to change notification settings - Fork 11
/
elisp-lookup.lisp
31 lines (25 loc) · 922 Bytes
/
elisp-lookup.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(defpackage :elisp-lookup (:use :cl)
(:export :populate-table :symbol-lookup))
(in-package :elisp-lookup)
(defparameter *elisp-root* "http://www.gnu.org/software/emacs/elisp-manual/html_node/")
(defparameter *elisp-file*
(merge-pathnames "elisp-symbols.lisp-expr"
(or #.*compile-file-truename* *default-pathname-defaults*)))
(defvar *table* nil)
(defvar *populated-p* nil)
(defun populate-table ()
(unless *populated-p*
(with-open-file (r *elisp-file* :direction :input)
(setf *table* (make-hash-table :test #'equalp))
(let ((s (read r)))
(loop for i in s do (setf (gethash (car i) *table*) (cdr i))))
'done)
(setf *populated-p* t)))
(defun symbol-lookup (symbol)
(unless *populated-p*
(populate-table))
(multiple-value-bind (val found)
(gethash symbol *table*)
(if found
(concatenate 'string *elisp-root*
val))))