Re: [racket-users] Re: Concise way to get completions for Racket code?

2018-02-16 Thread Greg Hendershott
As far as I can tell, certain features will work better -- or work at
all -- if you arrange to have some of your tool's code running "in" or
"alongside" the user's live program.

Otherwise, you can still do some useful things, but they may be
limited and/or surprising to the user.

For example, for completion:

- The candidates could be "a static list of whatever
namespace-mapped-symbols returns for #lang racket" -- but (a) that's
just one #lang, plus (b) it omits the user module's own defined
symbols.

- Or you could say, "well, I'll separately require the user's .rkt
file and get the symbols", but (a) it will get stale as they edit and
worse (b) what if the user's file has a top-level side-effecting
expression like `(delete-things-on-disk)`, which you've now run
unexpectedly.

Instead, you'll probably want to do namespace-mapped-symbols on the
namespace corresponding to the program the user is actually running
with your tool.

That's why I asked if your tool is running the user's program and
creating a REPL. You don't necessarily need to start with that
approach. But I think someday you'll probably end up there?

-- 
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: Concise way to get completions for Racket code?

2018-02-16 Thread HiPhish
Thank you for the offer, but I am currently tied up myself a lot. I was just
looking into this because the topic had popped up here.

I should have provided some context as to how the Neovim Racket client 
works.
When I'm experimenting I use the regular REPL from my terminal, not the 
client,
that's why I mentioned the REPL. In a real remote plugin it works like this:
when Neovim calls a function that's defined by a remote plugin an API client
process is started, which can then receive responses, notifications and send
back responses (using the MessagePack RPC protocol).

Let's say I have a remote plugin like this:

  #lang racket
  (require nvim)

  (nvim-function "GetTwo" (λ (args) 2))

This defines a function called `GetTwo` that can be called from Neovim. 
Neovim
then sends a request to the Racket client, the client executes the function 
`(λ
(args) 2)` and sends the result (the integer `2` in this case) back to 
Neovim.

For a completion plugin Neovim would send the current portion of the word to
complete (and if necessary other information like the current file name) and
Racket would return a list of matching symbol names. The function defined on
the Neovim side is really just an interface wrapper for sending a message to
the client, all the heavy lifting can be done in Racket.


On Thursday, February 15, 2018 at 7:52:24 PM UTC+1, Greg Hendershott wrote:
>
> I guess I'm not clear who does what, e.g. do you start a REPL for the 
> user? 
>
> If so, the `current-namespace` that's in effect when you call 
> `read-eval-print-loop` should probably come from doing 
> `(dynamic-require mp #f)` then the result of `(module->namespace mp)` 
> (where `mp` is a module path).  That same namespace is the one you'd 
> want to give to `namespace-mapped-symbols` for a list of completion 
> candidates. 
>
> p.s. Feel free to look at racket-mode code for ideas. However that's 
> accumulated a lot of moving parts; so I'm not sure if it's a great 
> example as a starting point. 
>
> p.p.s. Also see xrepl. 
>
> p.p.p.s. Although I'm tied up now through next week, I'd be happy to 
> hop on IRC or Slack or 1:1 email sometime after Feb 25, and talk 
> through ideas if that would help? 
>

-- 
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: Concise way to get completions for Racket code?

2018-02-14 Thread Greg Hendershott
> Wow, this sounds like just the right thing. But the question is, how does
> one
> get the namespace of the current text buffer? I guess I would need to
> somehow
> send the buffer contents over to Racket and build a namespace out of that?

`module->namespace` will give you a namespace "inside" a module.

The module can be the "top" module corresponding to a .rkt file using
`#lang`, or any nested submodule.

-- 
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: Concise way to get completions for Racket code?

2018-02-13 Thread HiPhish
Wow, this sounds like just the right thing. But the question is, how does 
one
get the namespace of the current text buffer? I guess I would need to 
somehow
send the buffer contents over to Racket and build a namespace out of that?

On Tuesday, February 13, 2018 at 1:39:49 PM UTC+1, William G Hatch wrote:
>
> Another function that may be useful for you is 
> `namespace-mapped-symbols`.  The readline library uses this to provide 
> completion in the repl. 
>

-- 
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: Concise way to get completions for Racket code?

2018-02-13 Thread HiPhish


On Monday, February 12, 2018 at 9:02:20 AM UTC+1, Gour wrote:
>
>
> I had tried tried several times with Emacs, but, for some strange reason, 
> very 
> soon I would experience some wrist pain and finally gave up on it. 
>
> Otoh, it does never occur when using Vim...yes, I also have Neovim 
> installed 
> and start using/learning it, but it is still light usage. 
>

For what it's worth, there is Evil Mode for Emacs. I have no idea how it
compares, as I said, I don't use Emacs, but maybe that's something for you.
Personally I try to use the home-row keys as much as possible, contorting my
wrist to reach ESC or the arrow keys, or stretching to reach the F-keys is
awful. My only problem is when the fingers on my left hand start hurting 
from
pressing Shift or CTRL (which I have mapped to Caps Lock) too often.

-- 
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: Concise way to get completions for Racket code?

2018-02-13 Thread nocheroot
This is definitely pointing me where I want to go, thanks.

#lang racket

(let ([n (make-base-namespace)])
  (parameterize ([current-namespace n])
(eval '(define oneplusone (+ 1 1)))
(filter (lambda (y) (regexp-match #px"^one" y))
(map (lambda (x) (symbol->string x)) (namespace-mapped-symbols 
n)



On Tuesday, February 13, 2018 at 6:39:49 AM UTC-6, William G Hatch wrote:
>
> >On Wednesday, February 7, 2018 at 5:12:00 PM UTC-6, noch...@gmail.com 
> wrote: 
> >> 
> >> My google-fu is failing me today.  Is there a concise way in Racket to 
> >> request possible completions for some Racket code? 
>
> Another function that may be useful for you is 
> `namespace-mapped-symbols`.  The readline library uses this to provide 
> completion in the repl. 
>

-- 
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: Concise way to get completions for Racket code?

2018-02-13 Thread William G Hatch

On Wednesday, February 7, 2018 at 5:12:00 PM UTC-6, noch...@gmail.com wrote:


My google-fu is failing me today.  Is there a concise way in Racket to
request possible completions for some Racket code?


Another function that may be useful for you is
`namespace-mapped-symbols`.  The readline library uses this to provide
completion in the repl.

--
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: Concise way to get completions for Racket code?

2018-02-12 Thread Gour
On Mon, 12 Feb 2018 03:37:54 -0500
Neil Van Dyke  wrote:

> Regarding Emacs (Esc-Meta-Alt-Ctrl-Shift) specifically... The Emacs
> features that reduce the amount of repetitive typing required (for,
> e.g., formatting, completion, navigation) are good, but what's bad
> for some people is that Emacs encourages simultaneous keypresses. If
> you're using one hand to press two keys simultaneously, the
> repetitive contortions involved seem to be a problem.  

Very true.

> Five things you can do, to save your hands : (1) for 2-simultaneous-key
> combinations, train yourself to use both hands; (2) for the Emacs Meta key,
> instead of holding down the Alt key and pressing the modified key(s),
> consider the pressing and releasing the Esc key, and then pressing the
> modified key(s); (3) add your own easier Emacs key bindings for commands you
> use often, perhaps your F keys; (4) try out Emacs features and add-ons that
> might save typing; (5) write your own Emacs functions to save typing.

I also tried with sticky-keys...

> There's also non-Emacs-specific things, like keyboard height, wrist
> angles, torso and arm positions, neck position, taking breaks,
> stress, etc.  Very subtle changes here can make all the difference.
> Different things work for different people, so Google around, and
> find what works for you.

I am aware of that, but I do not have any problem when using (n)vim.

> I was very fortunate that others started raising issues about typing
> RSI at the start of my career, so I just try to spread the gospel of
> good typing.

Thank you for the tips. ;)


Sincerely,
Gour

-- 
The work of a man who is unattached to the modes of material
nature and who is fully situated in transcendental knowledge
merges entirely into transcendence.


-- 
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: Concise way to get completions for Racket code?

2018-02-12 Thread Neil Van Dyke

Gour wrote on 02/12/2018 03:01 AM:
I had tried tried several times with Emacs, but, for some strange 
reason, very soon I would experience some wrist pain and finally gave 
up on it.


Something that's not Racket-specific, but is very important to software 
developers...


I've seen several developers cause permanent damage to their 
wrists/hands, from bad typing practice, and a few of them had to find 
jobs that didn't involve typing.


Never type through hand pain, and find good workstation ergonomics that 
work for you.


Regarding Emacs (Esc-Meta-Alt-Ctrl-Shift) specifically... The Emacs 
features that reduce the amount of repetitive typing required (for, 
e.g., formatting, completion, navigation) are good, but what's bad for 
some people is that Emacs encourages simultaneous keypresses. If you're 
using one hand to press two keys simultaneously, the repetitive 
contortions involved seem to be a problem.  Five things you can do, to 
save your hands :

(1) for 2-simultaneous-key combinations, train yourself to use both hands;
(2) for the Emacs Meta key, instead of holding down the Alt key and 
pressing the modified key(s), consider the pressing and releasing the 
Esc key, and then pressing the modified key(s);
(3) add your own easier Emacs key bindings for commands you use often, 
perhaps your F keys;

(4) try out Emacs features and add-ons that might save typing;
(5) write your own Emacs functions to save typing.

There's also non-Emacs-specific things, like keyboard height, wrist 
angles, torso and arm positions, neck position, taking breaks, stress, 
etc.  Very subtle changes here can make all the difference. Different 
things work for different people, so Google around, and find what works 
for you.


I was very fortunate that others started raising issues about typing RSI 
at the start of my career, so I just try to spread the gospel of good 
typing.


--
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: Concise way to get completions for Racket code?

2018-02-12 Thread Gour
On Sun, 11 Feb 2018 16:12:34 -0800 (PST)
HiPhish  wrote:

> One large advantage DrRacket has is its graphics capabilities. 

That's somehing I would just have to discover. :-)

> What's really cool about Neovim is that the developers have been de-crufting
> Vim. For example, GUIs are now independent of the editor itself, you could
> even use another editor like Atom and embed Neovim. In the past you would
> have had to use a Vim emulator, which is usually a hit or miss, but now you
> can just embed the real thing. Remote plugins I have already mentioned; in
> Vim if you want to write plugins in another language you have to re-compile
> Vim, with Neovim you just retrofit it. Then there is all the async stuff
> which was the prime motivation for starting Neovim. I was still new to Vim
> when I was getting really annoyed about things like syntax-checking always
> blocking and I was considering switching to Emacs, but then I discovered
> Neovim.

I had tried tried several times with Emacs, but, for some strange reason, very
soon I would experience some wrist pain and finally gave up on it.

Otoh, it does never occur when using Vim...yes, I also have Neovim installed
and start using/learning it, but it is still light usage.

My question was simply curiosity whether using non-Emacs editor is an obstacle
'forcing' me to choose some other language to tinker with. Of course, DrRacket
is always a viable option, but I simply prefer not to 'change gears' (aka
editors), if possible, when working.


> Emacs is older than Neovim and I don't think anyone here on this mailing list
> is using Neovim (except me)

:-)

> but people do use Emacs, so the Emacs-Racket ecosystem (and Lisp in general)
> has had more time to mature. It will be a while before Racket support in
> Neovim catches up with Emacs.

Thank you very much for your input!


Sincerely,
Gour

-- 
As a strong wind sweeps away a boat on the water,
even one of the roaming senses on which the mind
focuses can carry away a man's intelligence.


-- 
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: Concise way to get completions for Racket code?

2018-02-11 Thread Gour
On Fri, 9 Feb 2018 15:01:40 -0800 (PST)
HiPhish  wrote:

> I wrote the Racket client for cases like these where I can use a Racket
> library to solve a problem in Neovim. In the future if someone implements
> proper semantic auto-completion for DrRacket I will be able to take that
> functionality and use it in Neovim as well.

Btw, what do oyu think how good is the Neovim+Racket match in comparison with
e.g. Emacs?


Sincerely,
Gour

-- 
For him who has conquered the mind, the mind is the best of
friends; but for one who has failed to do so, his mind will
remain the greatest enemy.


-- 
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: Concise way to get completions for Racket code?

2018-02-09 Thread HiPhish
I'm afraid that's not possible. The functionality that gets the completion
candidates is written in Racket:

  #lang racket/base
 
  (require nvim/rplugin framework)
 
  (define (complete prefix)
(define completions (text:get-completions/manuals #f))
(filter (λ (x) (regexp-match (regexp-quote prefix) x)) completions))
 
  (nvim-function "RacketCompletions"
(λ (args)
  (complete (vector-ref args 0

Neovim has this feature called "remote plugins": a plugin can be written in 
any
language as long as there is an API client for it:
https://github.com/neovim/neovim/wiki/Related-projects#api-clients

I wrote the Racket client for cases like these where I can use a Racket 
library
to solve a problem in Neovim. In the future if someone implements proper
semantic auto-completion for DrRacket I will be able to take that 
functionality
and use it in Neovim as well.


On Friday, February 9, 2018 at 10:55:56 PM UTC+1, noch...@gmail.com wrote:
>
> Will your omni-completion also work in Vim?
>

-- 
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: Concise way to get completions for Racket code?

2018-02-09 Thread nocheroot
Will your omni-completion also work in Vim?

On Friday, February 9, 2018 at 3:52:30 PM UTC-6, HiPhish wrote:
>
> Thank you for finding that. I have used your snippet to add 
> omni-completion to
> Neovim now. I need to file down some rough patches before I make it a 
> plugin,
> but it works. Not as useful as having proper semantic completion would have
> been, it does not include identifiers from the current module and includes 
> all
> sorts of identifiers that haven't been imported. Still, better than 
> nothing I
> guess.
>
>
>
> 
>
>
> 
>
>
> On Thursday, February 8, 2018 at 11:28:21 PM UTC+1, noch...@gmail.com 
> wrote:
>>
>> 
>>
>

-- 
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: Concise way to get completions for Racket code?

2018-02-09 Thread HiPhish


Thank you for finding that. I have used your snippet to add omni-completion 
to
Neovim now. I need to file down some rough patches before I make it a 
plugin,
but it works. Not as useful as having proper semantic completion would have
been, it does not include identifiers from the current module and includes 
all
sorts of identifiers that haven't been imported. Still, better than nothing 
I
guess.







On Thursday, February 8, 2018 at 11:28:21 PM UTC+1, noch...@gmail.com wrote:
>
> 
>

-- 
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: Concise way to get completions for Racket code?

2018-02-08 Thread nocheroot


In case anyone else finds this helpful.  I poked around the DrRacket source 
and found text:get-completions/manuals.  This gave me a thread to pull.  
After more googling, docs, and reading more source I think I can answer my 
own question.


The short answer is no.


The long answer is sort of.  If I am understanding correctly, Racket does 
not provide the capability to directly look up lexical scope aware 
completions.  But, text:get-completions/manuals in framework can be used to 
look up a list of keywords in documented exports.  That list can then be 
searched for an applicable completion for a partial word.


Not sure why I failed to find this yesterday.


https://docs.racket-lang.org/framework/Text.html?q=text%3Aget-completions%2Fmanuals#%28def._%28%28lib._framework%2Fmain..rkt%29._text~3aget-completions%2Fmanuals%29%29


Here is a quick and dirty example.  There is probably a much better way to 
do this, but I'm still learning.  I'll settle for something that just works 
for now.


#lang racket
(require framework)

(filter (lambda (x) (regexp-match #px"^def" x)) 
(text:get-completions/manuals #f))




On Wednesday, February 7, 2018 at 5:12:00 PM UTC-6, noch...@gmail.com wrote:
>
> My google-fu is failing me today.  Is there a concise way in Racket to 
> request possible completions for some Racket code?  For example, in 
> powershell I can ask System.Management.Automation.CommandCompletion for 
> possible completions of the powershell code "ConvertTo-Json -"  like this:
>
> $cmd = "ConvertTo-Json -"
> $ret = 
> [System.Management.Automation.CommandCompletion]::MapStringInputToParsedInput($cmd,
>  
> $cmd.Length)
>
> $candidates = 
> [System.Management.Automation.CommandCompletion]::CompleteInput(
> $ret.Item1,
> $ret.Item2,
> $ret.Item3,
> $null,
> [System.Management.Automation.PowerShell]::Create()
> ).CompletionMatches
>
> $candidates | ForEach-Object {
> [pscustomobject]@{
> CompletionText = $_.CompletionText
> ResultType = $_.ResultType.ToString()
> ToolTip = $_.ToolTip
> }
> }
>
> Outputs (depending on system, powershell and .net version):
> CompletionText   ResultTypeToolTip 
> --   ----- 
> -InputObject ParameterName [Object] InputObject
> -Depth   ParameterName [int] Depth 
> -CompressParameterName [switch] Compress   
> -Verbose ParameterName [switch] Verbose
> -Debug   ParameterName [switch] Debug  
> -ErrorAction ParameterName [ActionPreference] ErrorAction  
> -WarningAction   ParameterName [ActionPreference] WarningAction
> -InformationAction   ParameterName [ActionPreference] InformationAction
> -ErrorVariable   ParameterName [string] ErrorVariable  
> -WarningVariable ParameterName [string] WarningVariable
> -InformationVariable ParameterName [string] InformationVariable
> -OutVariable ParameterName [string] OutVariable
> -OutBuffer   ParameterName [int] OutBuffer 
> -PipelineVariableParameterName [string] PipelineVariable   
>
>

-- 
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.