Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

racket-smart-open-bracket: Handle optional and typed argument forms #205

Open
andrew-kennedy opened this issue Feb 13, 2016 · 5 comments
Open

Comments

@andrew-kennedy
Copy link

In plai-typed, function arguments in definitions look like this:

(define (my-function [a : number] [b : symbol]) : (listof symbol)
    (list 'a 'b 'c))

smart-open-bracket does not handle inserting brackets in this case, reverting to parens. Just wanted to make the author aware, not sure if there's a good solution to this.

@greghendershott
Copy link
Owner

Thanks for the report. IIUC this is also relevant to #lang typed/racket and simply optional arguments in plain #lang racket.

@greghendershott
Copy link
Owner

The DrRacket feature upon which this is modeled doesn't seem to handle this case either. At least when I tried just now with Racket 6.3.

That doesn't mean racket-mode couldn't do better in this regard; just an observation.

@andrew-kennedy
Copy link
Author

That's interesting. I just tested in DrRacket 6.4 and it still doesn't function correctly. I'll probably just turn it off then, at least for typed Racket and plai-typed. Maybe something like general-close can provide a good enough solution for this, as opposed to using DrRacket's features.

@greghendershott
Copy link
Owner

Maybe something like general-close can provide a good enough solution for this, as opposed to using DrRacket's features.

If you'd be happy with just the closing delimiter, racket-mode already does this for }, ], ). For instance C-h k ] says:

] runs the command racket-insert-closing, which is an interactive
compiled Lisp function in `racket-common.el'.

It is bound to }, ], ).

(racket-insert-closing &optional PREFIX)

Insert a matching closing delimiter.

With a prefix, insert the typed character as-is.

@greghendershott
Copy link
Owner

Of course many people get matching closing delimiters from paredit, smartparens, or (in newer Emacs) electric-pair-mode. The smart open bracket works with all these, and the appeal is just hitting [ and it (hopefully) does the right thing.

Having said that, I don't actually use the smart open bracket feature in racket-mode, myself. I added it on request.

@greghendershott greghendershott changed the title racket-smart-open-bracket doesn't know about #lang plai-typed racket-smart-open-bracket: Handle optional and typed argument forms Feb 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants