summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-07-28 01:08:25 +0200
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-07-28 01:08:25 +0200
commit32f9cb274bc9abc16449d2da50df537c82cc7775 (patch)
tree70bdaee986544bb0ea5978bc33cbed47957fc003
parent235543503d09a52a513054ed75ac2506b7ce87bf (diff)
downloadgeiser-chez-32f9cb274bc9abc16449d2da50df537c82cc7775.tar.gz
geiser-chez-32f9cb274bc9abc16449d2da50df537c82cc7775.tar.bz2
Displaying variable values in autodoc.
-rw-r--r--elisp/geiser-autodoc.el7
-rw-r--r--elisp/geiser-syntax.el31
-rw-r--r--scheme/guile/geiser/doc.scm7
-rw-r--r--scheme/racket/geiser/autodoc.rkt9
4 files changed, 31 insertions, 23 deletions
diff --git a/elisp/geiser-autodoc.el b/elisp/geiser-autodoc.el
index 06a10e7..1af0ae2 100644
--- a/elisp/geiser-autodoc.el
+++ b/elisp/geiser-autodoc.el
@@ -131,11 +131,16 @@ when `geiser-autodoc-display-module-p' is on."
(defun geiser-autodoc--str* (full-signature)
(geiser-autodoc--str (list (car full-signature)) full-signature))
+(defsubst geiser-autodoc--value-str (proc module value)
+ (let ((name (geiser-autodoc--proc-name proc module)))
+ (if value (format "%s => %s" name value) name)))
+
(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)
+ (if (not args)
+ (geiser-autodoc--value-str proc module (cdr (assoc 'value signature)))
(save-current-buffer
(set-buffer (geiser-syntax--font-lock-buffer))
(erase-buffer)
diff --git a/elisp/geiser-syntax.el b/elisp/geiser-syntax.el
index 6240e75..3e8d590 100644
--- a/elisp/geiser-syntax.el
+++ b/elisp/geiser-syntax.el
@@ -217,24 +217,21 @@
(if (cdr (last p)) (1+ (safe-length p)) (length p)))
(defun geiser-syntax--scan-sexps (&optional begin)
- (let ((path))
+ (let* ((fst (symbol-at-point))
+ (path (and fst `((,fst 0)))))
(save-excursion
- (save-restriction
-;; (narrow-to-region (or begin (point-min)) (1+ (point)))
- (geiser-syntax--skip-comment/string)
- (while (not (zerop (geiser-syntax--nesting-level)))
- (let ((boundary (1+ (point))))
- (backward-up-list)
- (let ((form
- (nth-value 0 (geiser-syntax--form-after-point boundary))))
- (when (and (listp form) (car form) (symbolp (car form)))
- (let* ((len-1 (1- (geiser-syntax--pair-length form)))
- (prev (and (> len-1 1) (nth (1- len-1) form)))
- (prev (and (keywordp prev) (list prev))))
- (push `(,(car form) ,len-1 ,@prev) path))))))
- (if path (nreverse path)
- (let ((fst (symbol-at-point)))
- (and fst `((,fst 0)))))))))
+ (geiser-syntax--skip-comment/string)
+ (while (not (zerop (geiser-syntax--nesting-level)))
+ (let ((boundary (1+ (point))))
+ (backward-up-list)
+ (let ((form
+ (nth-value 0 (geiser-syntax--form-after-point boundary))))
+ (when (and (listp form) (car form) (symbolp (car form)))
+ (let* ((len-1 (1- (geiser-syntax--pair-length form)))
+ (prev (and (> len-1 1) (nth (1- len-1) form)))
+ (prev (and (keywordp prev) (list prev))))
+ (push `(,(car form) ,len-1 ,@prev) path)))))))
+ (nreverse path)))
(defsubst geiser-syntax--binding-form-p (bfs sbfs f)
(or (memq f '(define define* lambda let let* letrec))
diff --git a/scheme/guile/geiser/doc.scm b/scheme/guile/geiser/doc.scm
index 8c00e22..0d6b451 100644
--- a/scheme/guile/geiser/doc.scm
+++ b/scheme/guile/geiser/doc.scm
@@ -49,8 +49,11 @@
,@(let ((rest (assq-ref as 'rest)))
(if rest (list "...") '())))
(key ,@(arglst as 'keyword))))
- (let ((args-list (map mkargs (if (list? args-list) args-list '()))))
- (list id (cons 'args args-list))))
+ (let* ((args-list (map mkargs (if (list? args-list) args-list '())))
+ (value (if (null? args-list)
+ (format #f "~s" (symbol->object id))
+ "")))
+ (list id (cons 'args args-list) (cons 'value value))))
(define default-macro-args '(((required ...))))
diff --git a/scheme/racket/geiser/autodoc.rkt b/scheme/racket/geiser/autodoc.rkt
index 9eb732d..9eaec15 100644
--- a/scheme/racket/geiser/autodoc.rkt
+++ b/scheme/racket/geiser/autodoc.rkt
@@ -26,17 +26,20 @@
(map (lambda (id) (or (autodoc* id) (list id))) ids)))
(define (autodoc* id)
+ (define (val)
+ (with-handlers ([exn? (const "")])
+ (format "~.a" (namespace-variable-value id))))
(and
(symbol? id)
(let* ([loc (symbol-location* id)]
[name (car loc)]
[path (cdr loc)]
- [sgns (and path (find-signatures path name id))]
- [sgns (and sgns (if (list? sgns) sgns '()))])
+ [sgns (and path (find-signatures path name id))])
(and sgns
`(,id
(name . ,name)
- (args ,@(map format-signature sgns))
+ (value . ,(if (list? sgns) "" (val)))
+ (args ,@(if (list? sgns) (map format-signature sgns) '()))
(module . ,(module-path-name->name path)))))))
(define (format-signature sign)