From af8cd551c9ed6cac332fcb4cfa17c5143b9d48a5 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 31 Oct 2010 02:34:30 +0100 Subject: Autodoc: fix for improper macro arglists scanning --- scheme/guile/geiser/doc.scm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'scheme/guile') diff --git a/scheme/guile/geiser/doc.scm b/scheme/guile/geiser/doc.scm index 4722238..f5471b5 100644 --- a/scheme/guile/geiser/doc.scm +++ b/scheme/guile/geiser/doc.scm @@ -87,12 +87,14 @@ (else #f)))) (define (macro-args tf) + (define* (collect args #:optional (req '())) + (cond ((null? args) (arglist->args `(,(reverse req) #f #f r #f))) + ((symbol? args) (arglist->args `(,(reverse req) #f #f r ,args))) + ((and (pair? args) (symbol? (car args))) + (collect (cdr args) (cons (car args) req))) + (else #f))) (let* ((pats (procedure-property tf 'patterns)) - (args (and pats (filter identity - (map (lambda (p) - (and (every symbol? p) - (list (cons 'required p)))) - pats))))) + (args (and pats (filter-map collect pats)))) (or (and args (not (null? args)) args) default-macro-args))) (define (arity->args art) -- cgit v1.2.3 From dff681a7e5641f350c0d18c178b7401e75b107d6 Mon Sep 17 00:00:00 2001 From: Jose Antonio Ortega Ruiz Date: Sun, 31 Oct 2010 15:13:19 +0100 Subject: Always fallback to edit-module in M-. --- elisp/geiser-completion.el | 5 +++++ elisp/geiser-edit.el | 16 ++++++++++++++-- scheme/guile/geiser/doc.scm | 13 +++++++------ 3 files changed, 26 insertions(+), 8 deletions(-) (limited to 'scheme/guile') diff --git a/elisp/geiser-completion.el b/elisp/geiser-completion.el index 5c2f604..d346190 100644 --- a/elisp/geiser-completion.el +++ b/elisp/geiser-completion.el @@ -214,6 +214,11 @@ we're looking for a module name.") (defsubst geiser-completion--symbol-begin (module) (funcall geiser-completion--symbol-begin-function module)) +(defun geiser-completion--module-at-point () + (save-excursion + (goto-char (geiser-completion--symbol-begin t)) + (ignore-errors (thing-at-point 'sexp)))) + (defsubst geiser-completion--prefix (module) (buffer-substring-no-properties (geiser-completion--symbol-begin module) (point))) diff --git a/elisp/geiser-edit.el b/elisp/geiser-edit.el index e8e439c..4d61edc 100644 --- a/elisp/geiser-edit.el +++ b/elisp/geiser-edit.el @@ -205,8 +205,10 @@ With prefix, asks for the symbol to edit." (geiser-completion--read-symbol "Edit symbol: "))) (cmd `(:eval (:ge symbol-location ',symbol))) (marker (point-marker))) - (geiser-edit--try-edit symbol (geiser-eval--send/wait cmd)) - (when marker (ring-insert find-tag-marker-ring marker)))) + (condition-case nil + (progn (geiser-edit--try-edit symbol (geiser-eval--send/wait cmd)) + (when marker (ring-insert find-tag-marker-ring marker))) + (error (geiser-edit-module-at-point))))) (defun geiser-pop-symbol-stack () "Pop back to where \\[geiser-edit-symbol-at-point] was last invoked." @@ -221,6 +223,16 @@ With prefix, asks for the symbol to edit." (let ((cmd `(:eval (:ge module-location '(:module ,module))))) (geiser-edit--try-edit module (geiser-eval--send/wait cmd) method))) + +(defun geiser-edit-module-at-point () + "Opens a new window visiting the module at point." + (interactive) + (let ((marker (point-marker))) + (geiser-edit-module (or (geiser-completion--module-at-point) + (geiser-completion--read-module))) + (when marker (ring-insert find-tag-marker-ring marker)))) + + (provide 'geiser-edit) ;;; geiser-edit.el ends here diff --git a/scheme/guile/geiser/doc.scm b/scheme/guile/geiser/doc.scm index f5471b5..902f2a3 100644 --- a/scheme/guile/geiser/doc.scm +++ b/scheme/guile/geiser/doc.scm @@ -66,16 +66,17 @@ (else 'variable))) (define (arguments proc) - (define (p-arguments prog) - (map (lambda (a) ((@@ (system vm program) arity->arguments-alist) prog a)) - (or (program-arities prog) '()))) + (define (p-args prog) + (let ((as (map (lambda (a) + ((@@ (system vm program) arity->arguments-alist) prog a)) + (or (program-arities prog) '())))) + (and (not (null? as)) as))) (define (clist f) (lambda (x) (let ((y (f x))) (and y (list y))))) (cond ((is-a? proc ) (generic-args proc)) + ((doc->args proc) => list) ((procedure-property proc 'arglist) => (clist arglist->args)) ((procedure-source proc) => (clist source->args)) - ((doc->args proc) => list) - ((program? proc) (let ((a (p-arguments proc))) - (and (not (null? a)) a))) + ((and (program? proc) (p-args proc))) ((procedure-property proc 'arity) => (clist arity->args)) (else #f))) -- cgit v1.2.3