1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-05 03:30:24 +02:00

* ls.scm (ls, lls): Handle no arguments as meaning to look in

`(current-module)'. (Patch from Thien-Thi Nguyen.)
This commit is contained in:
Jim Blandy 1999-06-18 10:16:10 +00:00
parent 0a27f7d30f
commit 67e6fa38cd

View file

@ -1,6 +1,6 @@
;;;; ls.scm --- functions for browsing modules
;;;;
;;;; Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
;;;; Copyright (C) 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
;;;;
;;;; This program is free software; you can redistribute it and/or modify
;;;; it under the terms of the GNU General Public License as published by
@ -35,6 +35,9 @@
;;;
;;; ls . various-names
;;;
;;; With no arguments, return a list of definitions in
;;; `(current-module)'.
;;;
;;; With just one argument, interpret that argument as the
;;; name of a subdirectory of the current module and
;;; return a list of names defined there.
@ -45,6 +48,9 @@
;;; (<subdir-name> . <names-defined-there>)
;;; ...)
;;;
;;; lls . various-names
;;;
;;; Analogous to `ls', but with local definitions only.
(define-public (local-definitions-in root names)
(let ((m (nested-ref root names))
@ -64,22 +70,26 @@
(module-uses m)))))))
(define-public (ls . various-refs)
(and (pair? various-refs)
(if (pair? various-refs)
(if (cdr various-refs)
(map (lambda (ref)
(cons ref (definitions-in (current-module) ref)))
various-refs)
(definitions-in (current-module) (car various-refs)))))
(definitions-in (current-module) (car various-refs)))
(definitions-in (current-module) '())))
(define-public (lls . various-refs)
(and (pair? various-refs)
(if (pair? various-refs)
(if (cdr various-refs)
(map (lambda (ref)
(cons ref (local-definitions-in (current-module) ref)))
various-refs)
(local-definitions-in (current-module) (car various-refs)))))
(local-definitions-in (current-module) (car various-refs)))
(local-definitions-in (current-module) '())))
(define-public (recursive-local-define name value)
(let ((parent (reverse! (cdr (reverse name)))))
(and parent (make-modules-in (current-module) parent))
(local-define name value)))
;;; ls.scm ends here