summaryrefslogtreecommitdiff
path: root/elisp/geiser-autodoc.el
diff options
context:
space:
mode:
authorJose Antonio Ortega Ruiz <jao@gnu.org>2010-11-19 21:13:56 +0100
committerJose Antonio Ortega Ruiz <jao@gnu.org>2010-11-19 21:13:56 +0100
commit481f0ea2e5577ad5bb1a718b8023af92202e7423 (patch)
tree4c62ceb15765a66cf4c0eef70917d01b8d9d280d /elisp/geiser-autodoc.el
parentf6b03b27810e70304b89fd6185437dcf35d27b94 (diff)
downloadgeiser-chez-481f0ea2e5577ad5bb1a718b8023af92202e7423.tar.gz
geiser-chez-481f0ea2e5577ad5bb1a718b8023af92202e7423.tar.bz2
Better argument display in autodoc
Simpler (we don't need no square brackets) and more correct (keywords display as keywords and we only include default values when available (Guile, i'm looking at you).
Diffstat (limited to 'elisp/geiser-autodoc.el')
-rw-r--r--elisp/geiser-autodoc.el36
1 files changed, 19 insertions, 17 deletions
diff --git a/elisp/geiser-autodoc.el b/elisp/geiser-autodoc.el
index 35a9834..5bdfb1a 100644
--- a/elisp/geiser-autodoc.el
+++ b/elisp/geiser-autodoc.el
@@ -84,12 +84,20 @@ when `geiser-autodoc-display-module-p' is on."
(cond ((null args) nil)
((listp args)
(cons (car args) (geiser-autodoc--sanitize-args (cdr args))))
- (t '(...))))
+ (t '...)))
+
+(defun geiser-autodoc--format-arg (a)
+ (if (and (listp a) (keywordp (car a)))
+ (if (and (cdr a) (listp (cdr a)))
+ (format "(#%s %s)" (car a) (cadr a))
+ (format "(#%s)" (car a)))
+ (format "%s" a)))
(defun geiser-autodoc--insert-arg-group (args current &optional pos)
+ (when args (insert " "))
(dolist (a (geiser-autodoc--sanitize-args args))
(let ((p (point)))
- (insert (format "%s" a))
+ (insert (geiser-autodoc--format-arg a))
(when (or (and (numberp pos)
(numberp current)
(setq current (1+ current))
@@ -107,22 +115,16 @@ when `geiser-autodoc-display-module-p' is on."
(defun geiser-autodoc--insert-args (args pos prev)
(let ((cpos 1)
(reqs (cdr (assoc 'required args)))
- (opts (cdr (assoc 'optional args)))
+ (opts (mapcar (lambda (a)
+ (if (and (symbolp a) (not (eq a '...))) (list a) a))
+ (cdr (assoc 'optional args))))
(keys (cdr (assoc 'key args))))
- (when reqs
- (insert " ")
- (setq cpos
- (geiser-autodoc--insert-arg-group reqs
- cpos
- (and (not (zerop pos)) pos))))
- (when opts
- (insert " [")
- (setq cpos (geiser-autodoc--insert-arg-group opts cpos pos)))
- (when keys
- (insert " [")
- (geiser-autodoc--insert-arg-group keys prev nil)
- (insert "]"))
- (when opts (insert "]"))))
+ (setq cpos
+ (geiser-autodoc--insert-arg-group reqs
+ cpos
+ (and (not (zerop pos)) pos)))
+ (setq cpos (geiser-autodoc--insert-arg-group opts cpos pos))
+ (geiser-autodoc--insert-arg-group keys prev nil)))
(defsubst geiser-autodoc--id-name (proc module)
(let ((str (if module