diff --git a/collects/drracket/tool-lib.rkt b/collects/drracket/tool-lib.rkt index 0bc0ffad9a..cf121a8966 100644 --- a/collects/drracket/tool-lib.rkt +++ b/collects/drracket/tool-lib.rkt @@ -906,12 +906,11 @@ all of the names in the tools library, for use defining keybindings (parameter-doc drracket:rep:after-expression - (parameter/c (or/c #f any/c)) + (parameter/c (or/c #f (-> void?))) top-level-expression @{This parameter is used by @method[drracket:rep:text% evaluate-from-port]. - When it is something other than @racket[#f], then DrRacket passes it to - @racket[eval] as the last thing that it does on the user's thread (before - cleaning up).}) + When it is a thunk, then DrRacket invokes the thunk on the user's thread + as the last thing it does (before cleaning up).}) diff --git a/collects/scribble/tools/drracket-buttons.rkt b/collects/scribble/tools/drracket-buttons.rkt index 9a91d24490..1df2a30893 100644 --- a/collects/scribble/tools/drracket-buttons.rkt +++ b/collects/scribble/tools/drracket-buttons.rkt @@ -30,24 +30,28 @@ [fn (parameterize ([drracket:rep:after-expression (λ () - (printf "scribble: loading xref\n") - (define xref ((dynamic-require 'setup/xref 'load-collections-xref))) - (printf "scribble: rendering\n") - (parameterize ([current-input-port (open-input-string "")]) - ((dynamic-require 'scribble/render 'render) - (list (eval 'doc)) - (list fn) - #:render-mixin (dynamic-require (if html? - 'scribble/html-render - 'scribble/pdf-render) - 'render-mixin) - #:xrefs (list xref))) - (cond - [html? - (send-url/file (path-replace-suffix fn suffix))] - [else - (parameterize ([current-input-port (open-input-string "")]) - (system (format "open \"~a\"" (path->string (path-replace-suffix fn suffix)))))]))]) + (define doc (with-handlers ((exn:fail? (λ (x) #f))) (eval 'doc))) + ;; if (eval 'doc) goes wrong, then we assume that's because of + ;; an earlier failure, so we just don't do anything. + (when doc + (printf "scribble: loading xref\n") + (define xref ((dynamic-require 'setup/xref 'load-collections-xref))) + (printf "scribble: rendering\n") + (parameterize ([current-input-port (open-input-string "")]) + ((dynamic-require 'scribble/render 'render) + (list doc) + (list fn) + #:render-mixin (dynamic-require (if html? + 'scribble/html-render + 'scribble/pdf-render) + 'render-mixin) + #:xrefs (list xref))) + (cond + [html? + (send-url/file (path-replace-suffix fn suffix))] + [else + (parameterize ([current-input-port (open-input-string "")]) + (system (format "open \"~a\"" (path->string (path-replace-suffix fn suffix)))))])))]) (send drs-frame execute-callback))] [else (message-box "Scribble" "Cannot render buffer without filename")]))))