diff options
author | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-28 16:25:52 +0100 |
---|---|---|
committer | Jose Antonio Ortega Ruiz <jao@gnu.org> | 2010-12-28 16:25:52 +0100 |
commit | 8982bb6bb2afce626cd60533cb582ae88259a402 (patch) | |
tree | 3f60f6a23c9be1e368a64115831404d2c54d2fcf /elisp | |
parent | 466b8f71a7d6375f55b2806fb949a91d774147c6 (diff) | |
download | geiser-guile-8982bb6bb2afce626cd60533cb582ae88259a402.tar.gz geiser-guile-8982bb6bb2afce626cd60533cb582ae88259a402.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.
Diffstat (limited to 'elisp')
-rw-r--r-- | elisp/geiser-autodoc.el | 44 | ||||
-rw-r--r-- | elisp/geiser-compile.el | 2 |
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))))) |