[racket] Alt/Option key as meta on Mac

From: jab at math.brown.edu (jab at math.brown.edu)
Date: Fri Nov 29 16:10:38 EST 2013

On Thu, Nov 28, 2013 at 10:33 PM, Robby Findler <robby at eecs.northwestern.edu
> wrote:

> Oh, I should have done that long ago. I've pushed something that lets you
> use alt as meta.
>

Just found it at https://github.com/plt/racket/commit/d95a6b02. Thank you
for adding this! And so quickly, to boot!

Can't wait to be able to use it. Extrapolating based on the release dates
of the last few versions, the next release should be out soon, I take it?
Is there a way to get Alt as Meta working in the meantime?

I've already figured out how to add a user-defined keybindings file to map
Ctrl+w to "backward-kill-word", as in the shell. In case it helps anyone
else:

#lang s-exp framework/keybinding-lang


(define (rebind key command)

  (keybinding

   key

   (λ (ed evt)

     (send (send ed get-keymap) call-function command ed evt #t))))


(rebind "control:w" "backward-kill-word")



Similarly I'd like to map Ctrl-u to "delete-to-beginning-of-line", but it
looks like that function doesn't come out of the box, and I haven't yet
tried to figure out how to add it.

One last behavior I miss from the shell (as well as other GUI IDEs with
REPLs, such as Python's IDLE) is the default mapping of Ctrl-p/Ctrl-n to
"previous/next command from history" rather than "move the cursor up/down",
which I need much less often. Tried to figure out how to change this, but
didn't see where the Meta-p/Meta-n mappings were defined
in collects/framework/private/keymap.rkt in the first place.

 Any advice on these would be much appreciated. And I'll start a new thread
if this is getting too off-topic for this one.


> The docs are wrong, tho, because even with the release version you should
> be able to use command as meta (not that you really want to...)
>

(I didn't see a Command as Meta option in preferences, but you're right
that I don't want that anyway.)

Thanks again for your help, Robby, and happy Thanksgiving weekend to
everyone celebrating.

Robby
>
>
> On Wed, Nov 27, 2013 at 9:43 PM, <jab at math.brown.edu> wrote:
>
>> Hey Racket Users,
>>
>> Just trying Racket for the first time, and very excited to finally be
>> learning it! I've been wanting to for years.
>>
>> Just had my first encounter with DrRacket, and am trying to get
>> comfortable with keyboard input. According to
>> http://docs.racket-lang.org/drracket/Keyboard_Shortcuts.html,
>>
>> On Windows and Mac OS X, Meta is only available through the Escape key.
>>>
>>
>> Sorry to see it's not possible to bind the Alt/Option key to Meta, as it
>> is with e.g. Terminal.app, as it would be a huge usability win; the Escape
>> key on most keyboards is one of the hardest to reach, aggravating RSI the
>> world over. In
>> http://lists.racket-lang.org/users/archive/2010-August/041085.html, a
>> post from 2010, Matthew Flatt alludes to adding support for Option as Meta
>> after a soon-coming GUI rewrite, but I found no further mention of it here,
>> on GitHub (https://github.com/plt/racket/search?q=meta&type=issues), or
>> elsewhere.
>>
>> Just thought I'd inquire again about the possibility. On the off chance
>> it's a matter of submitting a newcomer-friendly patch, I'd be delighted to
>> give it a shot.
>>
>> Thanks for reading, and thanks for the great work on Racket.
>>
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131129/a9c21b00/attachment.html>

Posted on the users mailing list.