[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-guile 441cc2a 037/284: Refactoring: local bindings
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-guile 441cc2a 037/284: Refactoring: local bindings discovery moved to schemeland. |
Date: |
Sun, 1 Aug 2021 18:29:11 -0400 (EDT) |
branch: elpa/geiser-guile
commit 441cc2a9ba563c55ec3dd6ed138f99f62464d5ea
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>
Refactoring: local bindings discovery moved to schemeland.
---
geiser/introspection.scm | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)
diff --git a/geiser/introspection.scm b/geiser/introspection.scm
index 7e468e7..fd6784d 100644
--- a/geiser/introspection.scm
+++ b/geiser/introspection.scm
@@ -149,10 +149,33 @@ The alist keys that are currently defined are `required',
`optional',
,@(if rest (list (cons 'rest 'rest)) '())))))
(else #f)))
-(define (completions prefix)
- (sort! (map symbol->string
- (apropos-internal (string-append "^" prefix)))
- string<?))
+(define (completions prefix . context)
+ (let ((context (and (not (null? context)) (car context)))
+ (prefix (string-append "^" (regexp-quote prefix))))
+ (append (filter (lambda (s) (string-match prefix s))
+ (map symbol->string (local-bindings context)))
+ (sort! (map symbol->string (apropos-internal prefix)) string<?))))
+
+(define (local-bindings form)
+ (define (body f) (if (> (length f) 2) (cddr f) '()))
+ (define (decl-list d)
+ (let loop ((d d) (s '()))
+ (cond ((null? d) s)
+ ((symbol? d) (cons d s))
+ (else (loop (cdr d) (cons (car d) s))))))
+ (let loop ((form form) (bindings '()))
+ (cond ((not (pair? form)) bindings)
+ ((list? (car form))
+ (loop (cdr form) (append (local-bindings (car form)) bindings)))
+ ((and (list? form) (< (length form) 2)) bindings)
+ ((memq (car form) '(define define* lambda))
+ (loop (body form) (append (decl-list (cadr form)) bindings)))
+ ((and (memq (car form) '(let let* letrec letrec*))
+ (list? (cadr form)))
+ (loop (body form) (append (map car (cadr form)) bindings)))
+ ((and (eq? 'let (car form)) (symbol? (cadr form)))
+ (loop (cons 'let (body form)) (cons (cadr form) bindings)))
+ (else (loop (cdr form) bindings)))))
(define (module-location name)
(make-location (module-filename name) #f))
- [nongnu] branch elpa/geiser-guile created (now 8dda28f), Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 3bb2a98 006/284: Don't let (ice-9 history) confuse the evaluator., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 849fc5f 002/284: Compile file., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 3fa6b34 004/284: Load file commands., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 1b60c6f 003/284: * scheme/guile/geiser/eval.scm: missing file in previous commit, Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 475fab3 005/284: README stuff., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 7d50479 001/284: Guile scheme files moved to scheme/guile., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile b20a784 010/284: Better arg lists., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile b853bac 009/284: Faster M-., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 9ff1f7e 033/284: Eval/load file in the correct module., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 441cc2a 037/284: Refactoring: local bindings discovery moved to schemeland.,
Philip Kaludercic <=
- [nongnu] elpa/geiser-guile ceca3e5 038/284: Display (quote foo) as 'foo in autodoc strings., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 4ab2e9c 016/284: Autodoc: try symbol at point first. Some cleanups., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile a64467d 022/284: New command to open module file., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 8c8790c 029/284: Capture backtrace. Fix load/compile from Emacs., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 8db7920 030/284: Better stack delimitation: include only frames relevant to the eval'd expression., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile c60b2e0 035/284: Put new procedure-arguments into (geiser introspection) until it goes upstream., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 0d62495 048/284: Fix autodoc support for multiline arities in documentation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 4a647eb 011/284: Faster, asynchronous autodoc., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 8cd5259 014/284: Small autodoc fixes., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 56671f6 015/284: New command to get docstrings (C-cC-d)., Philip Kaludercic, 2021/08/01