[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/geiser-guile 63c39be 019/284: Initial support for module n
From: |
Philip Kaludercic |
Subject: |
[nongnu] elpa/geiser-guile 63c39be 019/284: Initial support for module name completion. |
Date: |
Sun, 1 Aug 2021 18:29:08 -0400 (EDT) |
branch: elpa/geiser-guile
commit 63c39be594264298766fc56289c92396a1790541
Author: Jose Antonio Ortega Ruiz <jao@gnu.org>
Commit: Jose Antonio Ortega Ruiz <jao@gnu.org>
Initial support for module name completion.
---
geiser/emacs.scm | 3 ++-
geiser/introspection.scm | 69 +++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 67 insertions(+), 5 deletions(-)
diff --git a/geiser/emacs.scm b/geiser/emacs.scm
index 1458c73..3f2116a 100644
--- a/geiser/emacs.scm
+++ b/geiser/emacs.scm
@@ -30,7 +30,8 @@
ge:symbol-location
ge:compile-file
ge:load-file
- ge:docstring)
+ ge:docstring
+ ge:all-modules)
#:use-module ((geiser introspection)
:renamer (symbol-prefix-proc 'ge:))
#:use-module ((geiser eval)
diff --git a/geiser/introspection.scm b/geiser/introspection.scm
index 19ea2df..110ab01 100644
--- a/geiser/introspection.scm
+++ b/geiser/introspection.scm
@@ -25,7 +25,12 @@
;;; Code:
(define-module (geiser introspection)
- #:export (arguments completions symbol-location docstring)
+ #:export (arguments
+ completions
+ symbol-location
+ docstring
+ all-modules
+ module-children)
#:use-module (system vm program)
#:use-module (ice-9 session)
#:use-module (ice-9 documentation)
@@ -140,13 +145,69 @@
(display signature)
(newline)
(display type)
- (if modname (begin (display " in module ")
- (display modname)))
+ (if modname
+ (begin
+ (display " in module ")
+ (display modname)))
(newline)
- (if doc (begin (display doc)))))))
+ (if doc (display doc))))))
(define (docstring sym)
(with-output-to-string
(lambda () (display-docstring sym))))
+(define (all-modules)
+ (let ((roots ((@@ (ice-9 session) root-modules))))
+ (sort! (map (lambda (m)
+ (format "~A" (module-name m)))
+ (fold (lambda (m all)
+ (append (all-child-modules m) all))
+ roots
+ roots))
+ string<?)))
+
+(define (child-modules mod)
+ (delq mod ((@@ (ice-9 session) submodules) mod)))
+
+(define (all-child-modules mod)
+ (let ((children (child-modules mod)))
+ (fold (lambda (m all)
+ (append (all-child-modules m) all))
+ children children)))
+
+(define (module-children mod-name)
+ (let* ((elts (hash-fold classify-module-object
+ (list '() '() '())
+ (module-obarray (maybe-module-interface mod-name))))
+ (elts (map sort-symbols! elts)))
+ (list (cons 'modules (map (lambda (m) `(,@mod-name ,m)) (car elts)))
+ (cons 'procs (cadr elts))
+ (cons 'vars (caddr elts)))))
+
+(define (sort-symbols! syms)
+ (let ((cmp (lambda (l r)
+ (string<? (symbol->string l) (symbol->string r)))))
+ (sort! syms cmp)))
+
+(define (maybe-module-interface mod-name)
+ (catch #t
+ (lambda () (resolve-interface mod-name))
+ (lambda args (resolve-module mod-name))))
+
+(define (classify-module-object name var elts)
+ (let ((obj (and (variable-bound? var)
+ (variable-ref var))))
+ (cond ((not obj) elts)
+ ((and (module? obj) (eq? (module-kind obj) 'directory))
+ (list (cons name (car elts))
+ (cadr elts)
+ (caddr elts)))
+ ((or (procedure? obj) (program? obj) (macro? obj))
+ (list (car elts)
+ (cons name (cadr elts))
+ (caddr elts)))
+ (else (list (car elts)
+ (cadr elts)
+ (cons name (caddr elts)))))))
+
;;; introspection.scm ends here
- [nongnu] elpa/geiser-guile d71825c 058/284: Small bug fix., (continued)
- [nongnu] elpa/geiser-guile d71825c 058/284: Small bug fix., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile fe48642 008/284: M-. working for any symbol whose module can be located., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 75df3b1 024/284: Better symbol documentation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 8cb76f1 045/284: Breakdown of schemeland into neat submodules., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 7b77380 054/284: New command to display generic methods (C-cC-dg) implemented., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 33b8c53 066/284: Callers/callees (C-c <, C-c >)., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 3398bc2 012/284: Inconsequential refactorings., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile af1c5a3 013/284: Small improvements., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile a461795 017/284: Better docstring., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 6f2ed87 018/284: Recognise empty doc string in Emacs side. Small refactorings., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 63c39be 019/284: Initial support for module name completion.,
Philip Kaludercic <=
- [nongnu] elpa/geiser-guile 06fabb2 020/284: Compile command adapted to new compiled-file-name behaviour., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 3432ccf 021/284: New command: module documentation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 08ba036 023/284: Separate commands for evaluation and compilation., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile d18c35b 025/284: Fix in symbol help signature displaying., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 3655a74 026/284: (geiser eval) functionality moved to (geiser emacs)., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 8377f5e 028/284: Refactoring of the eval/compile procedures., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 2ac3f91 027/284: Play nice with (ice-9 history) by using WRITE to return values to Emacs., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 49842df 031/284: Correct stack in load/compile file retorts., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 4608da2 032/284: Partial support for stack trace display., Philip Kaludercic, 2021/08/01
- [nongnu] elpa/geiser-guile 943e58b 039/284: Miscellaneous little fixes., Philip Kaludercic, 2021/08/01