slideshow: run a slideshow' or
main' submodule, if any
A common Slideshow pattern is to put a subset of slides in its own module with a `run-slides' function, and then you'd (un)comment a `(run-slides)' call at the end of the module to work on the subset by itself. Now, you can write `(module+ main (run-slides))' atthe end of the module and not have to comment it out. Adding `main' support to the `slideshow' executable makes it more consistent with using `racket' directly. Checking first for a `slideshow' submodule makes it possible for `slideshow' and `racket' to do different things, in case that's useful.
This commit is contained in:
parent
0c303ca9cd
commit
b098ca7aa6
|
@ -219,10 +219,11 @@ displays).
|
|||
|
||||
@defmodule[slideshow/start]
|
||||
|
||||
The @exec{slideshow} executable invokes the
|
||||
The @exec{slideshow} executable instantiates the
|
||||
@racketmodname[slideshow/start] module, which inspects the command
|
||||
line as reported by @racket[current-command-line-arguments] to get
|
||||
another module to provide the slide content. It also initializes
|
||||
another module to @racket[require] for the slide content.The @racketmodname[slideshow/start]
|
||||
module also initializes
|
||||
variables like @racket[printing?] and @racket[condense?] based on
|
||||
flags supplied on the command line.
|
||||
|
||||
|
@ -233,7 +234,14 @@ command
|
|||
|
||||
runs the slides.
|
||||
|
||||
The @exec{Slideshow} executable accepts a number of command-line
|
||||
If the module given to @exec{slideshow} has a @racketidfont{slideshow}
|
||||
submodule, then @racketmodname[slideshow/start] @racket[require]s the
|
||||
@racketidfont{slideshow} submodule after @racket[require]ing the
|
||||
module. If the module has no @racketidfont{slideshow} but has a
|
||||
@racketidfont{main} submodule, then the @racketidfont{main} submodule
|
||||
is @racket[require]d.
|
||||
|
||||
The @exec{slideshow} executable accepts a number of command-line
|
||||
flags. Use the @DFlag{help} flag to obtain a list of other
|
||||
flags.
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
mzlib/file
|
||||
mzlib/contract
|
||||
mred
|
||||
mzlib/cmdline
|
||||
racket/cmdline
|
||||
texpict/mrpict
|
||||
texpict/utils
|
||||
mzlib/math
|
||||
|
@ -57,10 +57,9 @@
|
|||
|
||||
(define file-to-load
|
||||
(command-line
|
||||
"slideshow"
|
||||
(current-command-line-arguments)
|
||||
[once-each
|
||||
(("-M" "--monitor") monitor "display to <monitor> (count from 0)"
|
||||
#:program "slideshow"
|
||||
#:once-each
|
||||
(("-M" "--monitor") monitor "display to <monitor> (count from 0)"
|
||||
(let ([n (string->number monitor)])
|
||||
(unless (and n (exact-nonnegative-integer? n))
|
||||
(die 'slideshow "argument to -M is not an exact non-negative integer: ~a" monitor))
|
||||
|
@ -102,16 +101,6 @@
|
|||
(("-m" "--no-smoothing")
|
||||
"disable anti-aliased drawing (usually faster)"
|
||||
(set! smoothing? #f))
|
||||
;; Disable --minutes, because it's not used
|
||||
#;
|
||||
(("-m" "--minutes") min "set talk duration in minutes"
|
||||
(let ([n (string->number min)])
|
||||
(unless (and n
|
||||
(integer? n)
|
||||
(exact? n)
|
||||
(positive? n))
|
||||
(die 'slideshow "argument to -m is not a positive exact integer: ~a" min))
|
||||
(set! talk-duration-minutes n)))
|
||||
(("-i" "--immediate") "no transitions"
|
||||
(set! use-transitions? #f))
|
||||
(("--trust") "allow slide program to write files and make network connections"
|
||||
|
@ -131,20 +120,12 @@
|
|||
(("--comment-on-slide") "display commentary on slide"
|
||||
(set! commentary? #t)
|
||||
(set! commentary-on-slide? #t))
|
||||
(("--time") "time seconds per slide" (set! print-slide-seconds? #t))]
|
||||
[args slide-module-file
|
||||
(cond
|
||||
[(null? slide-module-file) #f]
|
||||
[(null? (cdr slide-module-file))
|
||||
(let ([candidate (car slide-module-file)])
|
||||
(unless (file-exists? candidate)
|
||||
(die 'slideshow "expected a filename on the commandline, given: ~a"
|
||||
candidate))
|
||||
candidate)]
|
||||
[else (die 'slideshow
|
||||
"expects at most one module file, given ~a: ~s"
|
||||
(length slide-module-file)
|
||||
slide-module-file)])]))
|
||||
(("--time") "time seconds per slide" (set! print-slide-seconds? #t))
|
||||
#:ps
|
||||
"After requiring <slide-module-file>, if a `slideshow' submodule exists,"
|
||||
" it is required. Otherwise, if a `main' submodule exists, it is required."
|
||||
#:args ([slide-module-file #f])
|
||||
slide-module-file))
|
||||
|
||||
(define printing? (and printing-mode #t))
|
||||
|
||||
|
|
|
@ -64,7 +64,15 @@
|
|||
(lambda (who where-name where-port-num mode)
|
||||
(error 'slideshow
|
||||
"slide program attempted to make a network connection")))))
|
||||
(dynamic-require (path->complete-path content) #f))
|
||||
(define content-path (path->complete-path content))
|
||||
(dynamic-require content-path #f)
|
||||
(ormap (lambda (sm)
|
||||
(define submod-path `(submod ,content-path ,sm))
|
||||
(and (module-declared? submod-path #t)
|
||||
(begin
|
||||
(dynamic-require submod-path #f)
|
||||
#t)))
|
||||
'(slideshow main)))
|
||||
|
||||
(when (file-to-load)
|
||||
(load-content (string->path (file-to-load))))
|
||||
|
|
|
@ -5,6 +5,7 @@ Added raise-argument-error, raise-result-error,
|
|||
racket/contract: added procedure-arity-includes/c
|
||||
racket/sandbox: added sandbox-propagate-exceptions
|
||||
racket/cmdline: add #:ps for command-line
|
||||
slideshow/start: run a `slideshow' or `main' submodule, if any
|
||||
Changed impersonate-struct so that accessor impersonation requires
|
||||
work only if the field is accessible via the current impersonator
|
||||
or a mutator for the same field is also impersonated
|
||||
|
|
Loading…
Reference in New Issue
Block a user