summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-28 16:25:52 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-12-28 16:25:52 +0100
commit36ab77c75cdaaf21181d3017792d5f44c2b6c701 (patch)
tree524ad3ef07a1d375b078575722c2d61dac50edbd
parent29a65929e1107d941b328aff3f98b772c7f28c70 (diff)
downloadgeiser-36ab77c75cdaaf21181d3017792d5f44c2b6c701.tar.gz
geiser-36ab77c75cdaaf21181d3017792d5f44c2b6c701.tar.bz2
Leaner autodoc cache
We cannot consistently maintain a local cache, because of re-evaluations of external symbols will go unnoticed. The new strategy (remembering only the latest signatures) mostly works, although it introduces a bit of extra flickering every now and then. A global cache is perhaps worth considering.
-rw-r--r--elisp/geiser-autodoc.el44
-rw-r--r--elisp/geiser-compile.el2
2 files changed, 17 insertions, 29 deletions
diff --git a/elisp/geiser-autodoc.el b/elisp/geiser-autodoc.el
index 429d369..8ab89a6 100644
--- a/elisp/geiser-autodoc.el
+++ b/elisp/geiser-autodoc.el
@@ -54,39 +54,27 @@ when `geiser-autodoc-display-module-p' is on."
(make-variable-buffer-local
(defvar geiser-autodoc--cached-signatures nil))
-(defun geiser-autodoc--clean-cache (&optional whole)
- (if whole
- (setq geiser-autodoc--cached-signatures nil)
- (let ((s (car (last (geiser-syntax--locals-around-point nil nil))))
- (cache))
- (when s
- (dolist (item geiser-autodoc--cached-signatures)
- (unless (string-equal s (car item)) (push item cache)))
- (setq geiser-autodoc--cached-signatures (nreverse cache))))))
-
-(defun geiser-autodoc--save-signatures (ret)
- (let ((res (geiser-eval--retort-result ret)))
+(defsubst geiser-autodoc--clean-cache ()
+ (setq geiser-autodoc--cached-signatures nil))
+
+(defun geiser-autodoc--show-signatures (ret)
+ (let ((res (geiser-eval--retort-result ret))
+ (signs))
(when res
(dolist (item res)
- (push (cons (format "%s" (car item)) (cdr item))
- geiser-autodoc--cached-signatures))
- (let ((str (geiser-autodoc--autodoc (geiser-syntax--scan-sexps)
- geiser-autodoc--cached-signatures)))
- (when str (eldoc-message str))))))
+ (push (cons (format "%s" (car item)) (cdr item)) signs))
+ (let ((str (geiser-autodoc--autodoc (geiser-syntax--scan-sexps) signs)))
+ (when str (eldoc-message str)))
+ (setq geiser-autodoc--cached-signatures signs))))
(defun geiser-autodoc--get-signatures (funs)
(when funs
- (let ((missing) (cached))
- (if (not geiser-autodoc--cached-signatures)
- (setq missing funs)
- (dolist (f funs)
- (let ((cf (assoc f geiser-autodoc--cached-signatures)))
- (if cf (push cf cached) (push f missing)))))
- (when missing
- (let ((m (format "'(%s)" (mapconcat 'identity missing " "))))
- (geiser-eval--send `(:eval (:ge autodoc (:scm ,m)))
- 'geiser-autodoc--save-signatures)))
- cached)))
+ (let ((m (format "'(%s)" (mapconcat 'identity funs " "))))
+ (geiser-eval--send `(:eval (:ge autodoc (:scm ,m)))
+ 'geiser-autodoc--show-signatures)))
+ (and (or (assoc (car funs) geiser-autodoc--cached-signatures)
+ (assoc (cadr funs) geiser-autodoc--cached-signatures))
+ geiser-autodoc--cached-signatures))
(defun geiser-autodoc--sanitize-args (args)
(cond ((null args) nil)
diff --git a/elisp/geiser-compile.el b/elisp/geiser-compile.el
index f59f9e5..bc9aace 100644
--- a/elisp/geiser-compile.el
+++ b/elisp/geiser-compile.el
@@ -39,7 +39,7 @@
(path (cdr b/p))
(msg (format "%s %s ..." msg path)))
(message msg)
- (geiser-autodoc--clean-cache t)
+ (geiser-autodoc--clean-cache)
(geiser-compile--display-result
msg (geiser-eval--send/wait
`(,(if compile-p :comp-file :load-file) ,path)))))