Re: [racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Sam Tobin-Hochstadt
You can report an issue at https://github.com/racket/racket/issues

Sam
On Fri, Nov 30, 2018 at 10:56 AM Habib Alamin  wrote:
>
> Great points which I’d overlooked. It solved the immediate problem; thanks 
> for this improved approach.
>
> I’ll be implementing that soon (hoping it works). I just gotta decide where 
> to place the enter file for maximum reusability.
>
> Does anyone know where I could report this misfeature, by the way?
>
> Sent from my iPhone
>
> > On 30 Nov 2018, at 2:23 pm, Sam Tobin-Hochstadt  
> > wrote:
> >
> > I strongly recommend not doing this. In particular, it will break in
> > many situations. A few examples:
> > - any file that isn't written in #lang racket such as typed/racket or
> > scribble/manual or ...
> > - any file that doesn't work the same as a sequence of repl
> > interactions. For example, any use of mutual recursion or any
> > shadowing of imported ids
> > - any file that uses forms only allowed in modules, such as `module+`
> > or `provide`.
> >
> > I'm not sure why `-e` doesn't evaluate in the same namespace as the
> > REPL, but if you put `(enter! "my-file.rkt")` in `enter.rktl` then:
> >
> > $ racket -i -f enter.rktl
> >
> > will do what you want.
> >
> > You can generalize this to:
> >
> > (dynamic-enter! (vector-ref (current-command-line-arguments) 0))
> >
> > and then:
> >
> > $ racket -i -f enter.rktl my-file.rkt
> >
> > will do what you wanted.
> >
> > Sam
> >
> >
> >
> >> On Fri, Nov 30, 2018 at 4:36 AM Habib Alamin  wrote:
> >>
> >> I found a solution:
> >>
> >> nnoremap r :w \| !racket -e "$(grep -v '\#lang' %)" -i
> >>
> >> This little hack, instead of enter!ing a file, simply echoes the contents 
> >> of the file into the -e argument using a subshell. Racket treats newlines 
> >> the same as spaces, and ignores blank lines, but if you're a neat freak, 
> >> you can do:
> >>
> >> nnoremap r :w \| !racket -e "$(grep -Ev '(\#lang)\|(^$)' % \| tr 
> >> '\n' ' ')" -i
> >>
> >>> On Friday, 30 November 2018 01:36:11 UTC, Habib Alamin wrote:
> >>>
> >>> Hi,
> >>>
> >>> I'm trying to set up a keybinding in my editor to enter the namespace of 
> >>> my current file in a REPL, similar to how Dr Racket's Run button works.
> >>>
> >>> I can do a racket -e '(println "Hello!") -i and it loads the REPL after 
> >>> printing Hello. A racket -e '(define a "a") -i also works, in that I'm 
> >>> able to access a in the REPL. However, I can't do racket -e '(enter! 
> >>> "hello.rkt")' -i. The REPL starts, but I can't access anything defined in 
> >>> the file.
> >>>
> >>> After asking in the IRC channel, I was asked to try
> >>>
> >>> racket -e '(let ([racketrc-path (expand-user-path "~/.racketrc")]) (and 
> >>> (file-exists? racketrc-path) (load racketrc-path)) (void)) (enter! 
> >>> "current-file.rkt") (read-eval-print-loop)
> >>>
> >>> which didn't work either. Neither did
> >>>
> >>> racket -e '(enter! "file.rkt") (read-eval-print-loop)'
> >>>
> >>> I can do a racket -if file.rkt if I get rid of the #lang racket line, but 
> >>> I hear using -f isn't good practice, and besides, I want to write valid 
> >>> Racket files; removing the #lang line breaks normal Racket operation; I 
> >>> can't just do a racket file.rkt.
> >>>
> >>> I'd really appreciate any help in figuring out why this is happening and 
> >>> a simple fix.
> >>>
> >>> Cheers,
> >>> Habib
> >>
> >> --
> >> You received this message because you are subscribed to the Google Groups 
> >> "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send an 
> >> email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Habib Alamin
Great points which I’d overlooked. It solved the immediate problem; thanks for 
this improved approach.

I’ll be implementing that soon (hoping it works). I just gotta decide where to 
place the enter file for maximum reusability.

Does anyone know where I could report this misfeature, by the way?

Sent from my iPhone

> On 30 Nov 2018, at 2:23 pm, Sam Tobin-Hochstadt  wrote:
> 
> I strongly recommend not doing this. In particular, it will break in
> many situations. A few examples:
> - any file that isn't written in #lang racket such as typed/racket or
> scribble/manual or ...
> - any file that doesn't work the same as a sequence of repl
> interactions. For example, any use of mutual recursion or any
> shadowing of imported ids
> - any file that uses forms only allowed in modules, such as `module+`
> or `provide`.
> 
> I'm not sure why `-e` doesn't evaluate in the same namespace as the
> REPL, but if you put `(enter! "my-file.rkt")` in `enter.rktl` then:
> 
> $ racket -i -f enter.rktl
> 
> will do what you want.
> 
> You can generalize this to:
> 
> (dynamic-enter! (vector-ref (current-command-line-arguments) 0))
> 
> and then:
> 
> $ racket -i -f enter.rktl my-file.rkt
> 
> will do what you wanted.
> 
> Sam
> 
> 
> 
>> On Fri, Nov 30, 2018 at 4:36 AM Habib Alamin  wrote:
>> 
>> I found a solution:
>> 
>> nnoremap r :w \| !racket -e "$(grep -v '\#lang' %)" -i
>> 
>> This little hack, instead of enter!ing a file, simply echoes the contents of 
>> the file into the -e argument using a subshell. Racket treats newlines the 
>> same as spaces, and ignores blank lines, but if you're a neat freak, you can 
>> do:
>> 
>> nnoremap r :w \| !racket -e "$(grep -Ev '(\#lang)\|(^$)' % \| tr 
>> '\n' ' ')" -i
>> 
>>> On Friday, 30 November 2018 01:36:11 UTC, Habib Alamin wrote:
>>> 
>>> Hi,
>>> 
>>> I'm trying to set up a keybinding in my editor to enter the namespace of my 
>>> current file in a REPL, similar to how Dr Racket's Run button works.
>>> 
>>> I can do a racket -e '(println "Hello!") -i and it loads the REPL after 
>>> printing Hello. A racket -e '(define a "a") -i also works, in that I'm able 
>>> to access a in the REPL. However, I can't do racket -e '(enter! 
>>> "hello.rkt")' -i. The REPL starts, but I can't access anything defined in 
>>> the file.
>>> 
>>> After asking in the IRC channel, I was asked to try
>>> 
>>> racket -e '(let ([racketrc-path (expand-user-path "~/.racketrc")]) (and 
>>> (file-exists? racketrc-path) (load racketrc-path)) (void)) (enter! 
>>> "current-file.rkt") (read-eval-print-loop)
>>> 
>>> which didn't work either. Neither did
>>> 
>>> racket -e '(enter! "file.rkt") (read-eval-print-loop)'
>>> 
>>> I can do a racket -if file.rkt if I get rid of the #lang racket line, but I 
>>> hear using -f isn't good practice, and besides, I want to write valid 
>>> Racket files; removing the #lang line breaks normal Racket operation; I 
>>> can't just do a racket file.rkt.
>>> 
>>> I'd really appreciate any help in figuring out why this is happening and a 
>>> simple fix.
>>> 
>>> Cheers,
>>> Habib
>> 
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Sam Tobin-Hochstadt
I strongly recommend not doing this. In particular, it will break in
many situations. A few examples:
- any file that isn't written in #lang racket such as typed/racket or
scribble/manual or ...
- any file that doesn't work the same as a sequence of repl
interactions. For example, any use of mutual recursion or any
shadowing of imported ids
- any file that uses forms only allowed in modules, such as `module+`
or `provide`.

I'm not sure why `-e` doesn't evaluate in the same namespace as the
REPL, but if you put `(enter! "my-file.rkt")` in `enter.rktl` then:

$ racket -i -f enter.rktl

will do what you want.

You can generalize this to:

(dynamic-enter! (vector-ref (current-command-line-arguments) 0))

and then:

$ racket -i -f enter.rktl my-file.rkt

will do what you wanted.

Sam



On Fri, Nov 30, 2018 at 4:36 AM Habib Alamin  wrote:
>
> I found a solution:
>
> nnoremap r :w \| !racket -e "$(grep -v '\#lang' %)" -i
>
> This little hack, instead of enter!ing a file, simply echoes the contents of 
> the file into the -e argument using a subshell. Racket treats newlines the 
> same as spaces, and ignores blank lines, but if you're a neat freak, you can 
> do:
>
> nnoremap r :w \| !racket -e "$(grep -Ev '(\#lang)\|(^$)' % \| tr '\n' 
> ' ')" -i
>
> On Friday, 30 November 2018 01:36:11 UTC, Habib Alamin wrote:
>>
>> Hi,
>>
>> I'm trying to set up a keybinding in my editor to enter the namespace of my 
>> current file in a REPL, similar to how Dr Racket's Run button works.
>>
>> I can do a racket -e '(println "Hello!") -i and it loads the REPL after 
>> printing Hello. A racket -e '(define a "a") -i also works, in that I'm able 
>> to access a in the REPL. However, I can't do racket -e '(enter! 
>> "hello.rkt")' -i. The REPL starts, but I can't access anything defined in 
>> the file.
>>
>> After asking in the IRC channel, I was asked to try
>>
>> racket -e '(let ([racketrc-path (expand-user-path "~/.racketrc")]) (and 
>> (file-exists? racketrc-path) (load racketrc-path)) (void)) (enter! 
>> "current-file.rkt") (read-eval-print-loop)
>>
>> which didn't work either. Neither did
>>
>> racket -e '(enter! "file.rkt") (read-eval-print-loop)'
>>
>> I can do a racket -if file.rkt if I get rid of the #lang racket line, but I 
>> hear using -f isn't good practice, and besides, I want to write valid Racket 
>> files; removing the #lang line breaks normal Racket operation; I can't just 
>> do a racket file.rkt.
>>
>> I'd really appreciate any help in figuring out why this is happening and a 
>> simple fix.
>>
>> Cheers,
>> Habib
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread حبيب محمد ألأمين محمد ألهـاد
Thanks for the help, but I've already solved the problem; not sure if my second 
message went out.

I was looking for a very specific workflow, and I have it working now, so I no 
longer require any help (but am open to any criticisms of the workflow I have 
chosen).

Cheers,
Habib

> On 30 Nov 2018, at 13:58, Greg Hendershott  wrote:
> 
> If you have xrepl enabled (it is by default in recent Rackets), you
> get a bunch of handy commands. Try entering ,help to see them. One is
> ,enter.
> 
> So one common workflow is you keep one `racket` process running all
> the time, and simply type `,en /path/to/to/file.rkt` at the prompt.
> 
> If typing `,en /path/to/file.rkt` gets tiresome, then you can have
> your editor type this for you.
> 
> In Emacs you could do this by running `racket` in an Emacs
> shell/comint/terminal buffer and your Emacs key/command is a thin
> wrapper around comint-send-input or whatever.
> 
> In other editors, I don't know how to "send keys to some process"?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Greg Hendershott
If you have xrepl enabled (it is by default in recent Rackets), you
get a bunch of handy commands. Try entering ,help to see them. One is
,enter.

So one common workflow is you keep one `racket` process running all
the time, and simply type `,en /path/to/to/file.rkt` at the prompt.

If typing `,en /path/to/file.rkt` gets tiresome, then you can have
your editor type this for you.

In Emacs you could do this by running `racket` in an Emacs
shell/comint/terminal buffer and your Emacs key/command is a thin
wrapper around comint-send-input or whatever.

In other editors, I don't know how to "send keys to some process"?

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: How do I launch a REPL in the context of a file?

2018-11-30 Thread Habib Alamin
I found a solution:

nnoremap r :w \| !racket -e "$(grep -v '\#lang' %)" -i

This little hack, instead of enter!ing a file, simply echoes the contents 
of the file into the -e argument using a subshell. Racket treats newlines 
the same as spaces, and ignores blank lines, but if you're a neat freak, 
you can do:

nnoremap r :w \| !racket -e "$(grep -Ev '(\#lang)\|(^$)' % \| tr 
'\n' ' ')" -i

On Friday, 30 November 2018 01:36:11 UTC, Habib Alamin wrote:
>
> Hi,
>
> I'm trying to set up a keybinding in my editor to enter the namespace of 
> my current file in a REPL, similar to how Dr Racket's Run button works.
>
> I can do a racket -e '(println "Hello!") -i and it loads the REPL after 
> printing Hello. A racket -e '(define a "a") -i also works, in that I'm 
> able to access a in the REPL. However, I can't do racket -e '(enter! 
> "hello.rkt")' -i. The REPL starts, but I can't access anything defined in 
> the file.
>
> After asking in the IRC channel, I was asked to try
>
> racket -e '(let ([racketrc-path (expand-user-path "~/.racketrc")]) (and 
> (file-exists? racketrc-path) (load racketrc-path)) (void)) (enter! 
> "current-file.rkt") (read-eval-print-loop)
>
> which didn't work either. Neither did
>
> racket -e '(enter! "file.rkt") (read-eval-print-loop)'
>
> I can do a racket -if file.rkt if I get rid of the #lang racket line, but 
> I hear using -f isn't good practice, and besides, I want to write valid 
> Racket files; removing the #lang line breaks normal Racket operation; I 
> can't just do a racket file.rkt.
>
> I'd really appreciate any help in figuring out why this is happening and a 
> simple fix.
>
> Cheers,
> Habib
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.