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
commitb2b79169a4a7fab4de2f0337f5c850421a3ad3a0 (patch)
treea3aedaf38ef01a1c7d12c8dbd62ce8f6dba0c2f6 /elisp/geiser-autodoc.el
parent908fffdc3a35b61089626f7ac986d1f36af42162 (diff)
downloadgeiser-b2b79169a4a7fab4de2f0337f5c850421a3ad3a0.tar.gz
geiser-b2b79169a4a7fab4de2f0337f5c850421a3ad3a0.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