laurent.orseau
2020-4-22 14:32:37

@robby Currently for some reason it’s not possible to open a file in DrRacket from Quisckscript, but reordering tabs work. Any idea why?

More details: If you try this quickscript: #lang racket/base (require quickscript racket/gui/base racket/class) (define-script ask-open-in-tab #:label "ask-open-in-tab" (λ (selection #:frame fr) (define fi (get-file)) (when fi (send fr open-in-new-tab fi)) #f)) it barks: Error in script file "/home/lorseau/.racket/quickscript/user-scripts/ask-open-in-tab.rkt": namespace-attach-module: module not declared (in the source namespace) module name: #<resolved-module-path:"/usr/share/racket/pkgs/drracket/drracket/tool-lib.rkt"> From here: https://github.com/Metaxal/quickscript/blob/master/tool.rkt#L151

I have no idea what this means :confused:


robby
2020-4-22 15:04:49

Just guessing but maybe you need to add a require or a dynamic require of drracket/tool-lib before you parameterize yourself over to the new namespace? I’m not really clear why you’re making a new namespace, actually, so this may be bad advice. @laurent.orseau


laurent.orseau
2020-4-22 15:16:06

Each script is run in a new namespace to avoid interaction between the scripts.

A (dynamic or not) require of drracket/tool-lib would start an instance of DrRacket, wouldn’t it?


robby
2020-4-22 18:33:45

Well, DrRacket should already be started when quickscript is running, I suppose?


laurent.orseau
2020-4-22 18:34:41

I think it will start yet another instance. At least that’s what happens if your (require drracket/tool-lib) and run it in DrRacket. I don’t know how it all works though


robby
2020-4-22 18:34:42

If you create a new namespace and require it in the new namespace, it will attempt to start a new one.


laurent.orseau
2020-4-22 18:34:49

right, ok


robby
2020-4-22 18:36:11

DrRacket creates a new namespace (and new other things) to separate the user’s program from it’s own implementation


robby
2020-4-22 18:36:46

The error message you posted says “I cannot share that module because I don’t have it in this namespace to share”


robby
2020-4-22 18:37:21

So depending on what you want to do and what else is going on there are different ways to fix that.


robby
2020-4-22 18:38:42

If you’re not running inside DrRacket as a tool already then you would need to be there for this to work


robby
2020-4-22 18:39:29

if you’re a tool inside drracket already and you’re getting that, then maybe you’ve created a new namespace “too early”?


laurent.orseau
2020-4-22 19:25:54

Ok thanks. I kind of see, but I’m confused as of why rearranging drracket’s tabs works, but not opening a file in a new tab


robby
2020-4-22 20:16:39

Well, I can confidently say that it isn’t obvious to me from this description. Sorry!


laurent.orseau
2020-4-22 21:47:32

Ok thanks. I will need to look at the code, but maybe reorder-tabs bypasses some framework stuff and goes directly to the editor% whereas open-in-new-tab doesn’t. Is there a right way to make this available in the new namespace so that the script invoked in the namespace can use send on it?


dan.ml.901
2020-4-23 01:21:17

On macOS does anyone know why DrRacket doesn’t handle the “Hide ⌘H” command? It vanishes only for a split second…