mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-06 12:10:28 +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:
parent
0a27f7d30f
commit
67e6fa38cd
1 changed files with 15 additions and 5 deletions
20
ice-9/ls.scm
20
ice-9/ls.scm
|
@ -1,6 +1,6 @@
|
||||||
;;;; ls.scm --- functions for browsing modules
|
;;;; 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
|
;;;; 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
|
;;;; it under the terms of the GNU General Public License as published by
|
||||||
|
@ -35,6 +35,9 @@
|
||||||
;;;
|
;;;
|
||||||
;;; ls . various-names
|
;;; ls . various-names
|
||||||
;;;
|
;;;
|
||||||
|
;;; With no arguments, return a list of definitions in
|
||||||
|
;;; `(current-module)'.
|
||||||
|
;;;
|
||||||
;;; With just one argument, interpret that argument as the
|
;;; With just one argument, interpret that argument as the
|
||||||
;;; name of a subdirectory of the current module and
|
;;; name of a subdirectory of the current module and
|
||||||
;;; return a list of names defined there.
|
;;; return a list of names defined there.
|
||||||
|
@ -45,6 +48,9 @@
|
||||||
;;; (<subdir-name> . <names-defined-there>)
|
;;; (<subdir-name> . <names-defined-there>)
|
||||||
;;; ...)
|
;;; ...)
|
||||||
;;;
|
;;;
|
||||||
|
;;; lls . various-names
|
||||||
|
;;;
|
||||||
|
;;; Analogous to `ls', but with local definitions only.
|
||||||
|
|
||||||
(define-public (local-definitions-in root names)
|
(define-public (local-definitions-in root names)
|
||||||
(let ((m (nested-ref root names))
|
(let ((m (nested-ref root names))
|
||||||
|
@ -64,22 +70,26 @@
|
||||||
(module-uses m)))))))
|
(module-uses m)))))))
|
||||||
|
|
||||||
(define-public (ls . various-refs)
|
(define-public (ls . various-refs)
|
||||||
(and (pair? various-refs)
|
(if (pair? various-refs)
|
||||||
(if (cdr various-refs)
|
(if (cdr various-refs)
|
||||||
(map (lambda (ref)
|
(map (lambda (ref)
|
||||||
(cons ref (definitions-in (current-module) ref)))
|
(cons ref (definitions-in (current-module) ref)))
|
||||||
various-refs)
|
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)
|
(define-public (lls . various-refs)
|
||||||
(and (pair? various-refs)
|
(if (pair? various-refs)
|
||||||
(if (cdr various-refs)
|
(if (cdr various-refs)
|
||||||
(map (lambda (ref)
|
(map (lambda (ref)
|
||||||
(cons ref (local-definitions-in (current-module) ref)))
|
(cons ref (local-definitions-in (current-module) ref)))
|
||||||
various-refs)
|
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)
|
(define-public (recursive-local-define name value)
|
||||||
(let ((parent (reverse! (cdr (reverse name)))))
|
(let ((parent (reverse! (cdr (reverse name)))))
|
||||||
(and parent (make-modules-in (current-module) parent))
|
(and parent (make-modules-in (current-module) parent))
|
||||||
(local-define name value)))
|
(local-define name value)))
|
||||||
|
|
||||||
|
;;; ls.scm ends here
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue