summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2009-08-25 15:30:51 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2009-08-25 15:30:51 +0200
commit98e199daf7b1a56179b670c192c7d244fcb2b323 (patch)
treeb6de0e0dabfc0d2b44972d0da34bf9c32bcff7d7
parentf52ac22eb1c09f7eae9d53d7d12d15edac56f942 (diff)
downloadgeiser-chez-98e199daf7b1a56179b670c192c7d244fcb2b323.tar.gz
geiser-chez-98e199daf7b1a56179b670c192c7d244fcb2b323.tar.bz2
Slightly better autodoc caching (probably needs an overhaul, though).
-rw-r--r--elisp/geiser-autodoc.el33
-rw-r--r--elisp/geiser-company.el8
-rw-r--r--elisp/geiser-doc.el3
3 files changed, 23 insertions, 21 deletions
diff --git a/elisp/geiser-autodoc.el b/elisp/geiser-autodoc.el
index 5aa6691..c2746a0 100644
--- a/elisp/geiser-autodoc.el
+++ b/elisp/geiser-autodoc.el
@@ -68,7 +68,7 @@ when `geiser-autodoc-display-module-p' is on."
(make-variable-buffer-local
(defvar geiser-autodoc--cached-signatures nil))
-(defun geiser-autodoc--get-signatures (funs)
+(defun geiser-autodoc--get-signatures (funs &optional keep-cached)
(when funs
(let ((missing) (cached))
(if (not geiser-autodoc--cached-signatures)
@@ -77,14 +77,16 @@ when `geiser-autodoc-display-module-p' is on."
(let ((cf (assq f geiser-autodoc--cached-signatures)))
(if cf (push cf cached)
(push f missing)))))
- (unless cached
+ (unless (or cached keep-cached)
(setq geiser-autodoc--cached-signatures nil))
- (if (not missing) geiser-autodoc--cached-signatures
+ (when missing
(let ((res (geiser-eval--send/result `(:eval ((:ge autodoc)
(quote ,missing)))
500)))
(when res
- (setq geiser-autodoc--cached-signatures (append cached res))))))))
+ (setq geiser-autodoc--cached-signatures
+ (append res (if keep-cached geiser-autodoc--cached-signatures cached))))))
+ geiser-autodoc--cached-signatures)))
(defun geiser-autodoc--insert-args (args current &optional pos)
(dolist (a args)
@@ -109,8 +111,9 @@ when `geiser-autodoc-display-module-p' is on."
proc)))
(propertize str 'face 'geiser-font-lock-autodoc-procedure-name)))
-(defun geiser-autodoc--str (proc desc signature)
- (let ((args (cdr (assoc 'args signature)))
+(defun geiser-autodoc--str (desc signature)
+ (let ((proc (car desc))
+ (args (cdr (assoc 'args signature)))
(module (cdr (assoc 'module signature))))
(if (not args) (geiser-autodoc--proc-name proc module)
(let ((cpos 1)
@@ -140,15 +143,15 @@ when `geiser-autodoc-display-module-p' is on."
(insert ")")
(buffer-string))))))
-(defun geiser-autodoc--autodoc (path)
- (let* ((funs (mapcar 'car path))
- (signs (geiser-autodoc--get-signatures funs)))
- (when signs
- (catch 'signature
- (dolist (f funs)
- (let ((signature (cdr (assq f signs))))
- (when signature
- (throw 'signature (geiser-autodoc--str f (assq f path) signature)))))))))
+(defun geiser-autodoc--autodoc (path &optional keep-cached)
+ (let ((signs (geiser-autodoc--get-signatures (mapcar 'car path) keep-cached))
+ (p (car path))
+ (s))
+ (while (and path (not s))
+ (unless (setq s (cdr (assq (car p) signs)))
+ (setq p (car path))
+ (setq path (cdr path))))
+ (when s (geiser-autodoc--str p s))))
;;; Autodoc function:
diff --git a/elisp/geiser-company.el b/elisp/geiser-company.el
index 8ae8969..ef4ce38 100644
--- a/elisp/geiser-company.el
+++ b/elisp/geiser-company.el
@@ -38,7 +38,7 @@
(ignore-errors
(if module
(format "%s [module]" id)
- (geiser-autodoc--autodoc (list (list (intern id) 0))))))
+ (geiser-autodoc--autodoc (list (list (intern id) 0)) t))))
(defsubst geiser-company--doc-buffer (id module)
nil)
@@ -61,11 +61,11 @@
(defun geiser-company--setup (enable)
(setq geiser-company--enabled-flag enable)
+ (when (boundp 'company-lighter)
+ (setq company-lighter "/C"))
(when (fboundp 'company-mode)
(company-mode nil)
- (when enable (company-mode enable)))
- (when (boundp 'company-lighter)
- (setq company-lighter "/C")))
+ (when enable (company-mode enable))))
(defun geiser-company--inhibit-autodoc (ignored)
(setq geiser-autodoc--inhibit-flag t))
diff --git a/elisp/geiser-doc.el b/elisp/geiser-doc.el
index 8e5c816..29f0de2 100644
--- a/elisp/geiser-doc.el
+++ b/elisp/geiser-doc.el
@@ -175,8 +175,7 @@
(message "No documentation available for '%s'" symbol)
(geiser-doc--with-buffer
(erase-buffer)
- (geiser-doc--insert-title (geiser-autodoc--str (format "%s" symbol)
- nil
+ (geiser-doc--insert-title (geiser-autodoc--str (list (format "%s" symbol) 0)
(cdr (assoc 'signature ds))))
(newline)
(insert (or (cdr (assoc 'docstring ds)) ""))