[racket-dev] Bug in the documentation or the implementation

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon Mar 19 11:00:53 EDT 2012

[ re-added the dev mailing list ]

On Mon, Mar 19, 2012 at 7:44 AM, Antonio Menezes Leitao
<antonio.menezes.leitao at ist.utl.pt> wrote:
> Hi Robby,
>
> On Mon, Mar 19, 2012 at 12:00 PM, Robby Findler
> <robby at eecs.northwestern.edu> wrote:
>> I'm not able to reproduce this problem. I created a file, copied and
>> pasted the code from 3.3.9 in the DrRacket docs into the file,
>> selected the "Add User-defined Keybindings" menu item, chose the file,
>> and got no error. The keybindings also seem to work, I tried them with
>> this file:
>>
>> #lang racket/base
>> (+ 1 2)
>>
>> I selected the (+ 1 2) and typed control-c control-r and saw it appear
>> in the REPL.
>>
>> Are you doing something differently?
>
> I did the same thing, except that I restarted
> DrRacket after installing the keybindings. Quitting and
> starting again gives the following error on startup:
>
> Error when installing the keybindings F:\Users\aml\Desktop\keys.rkt:
>
> link: reference (phase 0) to a variable in module "C:\Program
> Files\Racket\collects\drracket\tool-lib.rkt" that is uninitialized
> (phase level 0); reference appears in module:
> "F:\Users\aml\Desktop\keys.rkt" in: drracket:unit:definitions-text<%>
>
> Did you try restarting DrRacket?

I didn't! Thanks, that's what I was missing.

> Ps: There is also a less serious error when invoking
> Ctrl-c Ctrl-e with the cursor _after_ the expression:
>
> Error running keybinding ...Desktop\keys.rkt:5:22
>
> send-range-to-repl: contract violation, expected:
> exact-positive-integer?, given: #f
>  contract from: (function send-range-to-repl), blaming:
> F:\Users\aml\Desktop\keys.rkt
>  contract:
>    (->
>     (is-a?/c interface:unit:definitions-text<%>)
>     exact-positive-integer?
>     exact-positive-integer?
>     boolean?
>     any)
>  at: F:\Users\aml\Desktop\keys.rkt:33.18

I've pushed a fix for both of these. If you don't want to deal with
git and whatnot (altho we've tried to make this easy and there are
nightly builds), then below is the relevant portion of the diff that
you can apply to get the main part of the fix (the line numbers may be
slightly different).

Thanks again!

Robby

diff --git a/collects/drracket/private/main.rkt
b/collects/drracket/private/main.rkt
index cc979bc..16b18c0 100644
--- a/collects/drracket/private/main.rkt
+++ b/collects/drracket/private/main.rkt
@@ -702,10 +702,6 @@
 ;;   not going to be exiting yet.
 (autosave:restore-autosave-files/gui)

-;; install user's keybindings
-(for-each drracket:frame:add-keybindings-item
-          (preferences:get 'drracket:user-defined-keybindings))
-
 ;; the initial window doesn't set the
 ;; unit object's state correctly, yet.
 (define (make-basic)
@@ -727,9 +723,12 @@
                 (loop (cdr files))
                 (cons (car files) (loop (cdr files))))])))


 (queue-callback
  (λ ()
+
+   ;; install user's keybindings
+   (for-each drracket:frame:add-keybindings-item
+             (preferences:get 'drracket:user-defined-keybindings))
+
    ;; NOTE: drscheme-normal.rkt sets current-command-line-arguments to
    ;; the list of files to open, after parsing out flags like -h
    (let* ([files-to-open


Posted on the dev mailing list.