Towards an easier Lozenge command character on Windows #73

Closed
opened 10 years ago by maphew · 12 comments
maphew commented 10 years ago (Migrated from github.com)

Typing the lozenge command character on Windows with Alt-nnnn is tedious at best, and doubly so on a laptop that doesn't have a numpad, and impossible on one without numlock at all.

There has to be a better way.

Command Overview has a note about using world:command-marker to configure the command character to something else (though where to define is left as an exercise for the reader). It's sub-optimal because it will make it harder to work collaboratively with others.

I got excited when I saw a post about enabling and using AltGr for a subset of Alt-codes, but lozenge doesn't seem to be in the Wikipedia list. (Which is what makes it good as a command character in the first place, it doesn't get used.)

What I'll probably do is leverage AutoHotKey and bind double-tap [some-key] (ref). This works for me because I'm using AHK already, others might find that as too much friction. I opened this issue in case someone has a better solution I haven't thought of?

Typing the lozenge command character `◊` on Windows with Alt-nnnn is tedious at best, and doubly so [on a laptop](http://fsymbols.com/keyboard/windows/alt-codes/laptop/) that doesn't have a numpad, and impossible on one without numlock at all. There has to be a better way. [Command Overview](http://pkg-build.racket-lang.org/doc/pollen/reader.html) has a note about using `world:command-marker` to configure the command character to something else (though where to define is left as an exercise for the reader). It's sub-optimal because it will make it harder to work collaboratively with others. I got excited when I saw a post about enabling and using [`AltGr` for a subset of Alt-codes](http://superuser.com/a/459800/16966), but lozenge doesn't seem to be in [the Wikipedia list](https://en.wikipedia.org/wiki/AltGr_key). (Which is what makes it good as a command character in the first place, it doesn't get used.) What I'll probably do is leverage AutoHotKey and bind _double-tap [some-key]_ ([ref](http://stackoverflow.com/questions/1794258/detect-a-double-key-press-in-autohotkey)). This works for me because I'm using AHK already, others might find that as too much friction. I opened this issue in case someone has a better solution I haven't thought of?
mbutterick commented 10 years ago (Migrated from github.com)

You can override the command character on a per-project basis using a config submodule in your "directory-require.rkt" file. You are correct, however, that there ought to be a cross-reference in the “Command Overview” docs (and now, there is).

As for the ergonomics, I acknowledge that the lozenge is not easy to type (even on a Mac keyboard — I use a utility called Typinator to assign it to a more convenient location).

You can override the command character on a per-project basis using a `config` submodule in your `"directory-require.rkt"` file. You are correct, however, that there ought to be a cross-reference in the “Command Overview” docs (and now, there is). As for the ergonomics, I acknowledge that the lozenge is not easy to type (even on a Mac keyboard — I use a utility called Typinator to assign it to a more convenient location).
mbutterick commented 10 years ago (Migrated from github.com)

BTW the instructions to change the command char.

BTW [the instructions](http://pkg-build.racket-lang.org/doc/pollen/World.html#%28part._.Settable_values%29) to change the command char.
maphew commented 10 years ago (Migrated from github.com)

Thank you for documentation (and promptness!)

Here's a working AHK script to have double-tap back-tick send the lozenge character. It took way more time than I want to think about, once started I couldn't let go.

; -={ tick-tick-lozenge.ahk }=-
; Double-tap backtick sends Pollen command character (◊)
; For some reason I needed to use Unicode 'U+25CA' 
; instead of the standard alt-code '9674'
;
; Adapted from http://ahkscript.org/docs/commands/SetTimer.htm
; and http://www.autohotkey.com/board/topic/145507-how-to-use-double-tap-backtick-with-pass-through/
;
#EscapeChar \
$`::
if winc_presses > 0 
    {winc_presses += 1
    return
    }

winc_presses = 1
SetTimer, TheKey, 250 ; Wait for more presses, in milliseconds
return

TheKey:
    SetTimer, TheKey, off
    if winc_presses = 1 ; The key was pressed once.
        {Send `
        }
    else if winc_presses = 2 ; The key was pressed twice.
        {Send {U+25CA}
        }

; Regardless of which action above was triggered, reset the count to
; prepare for the next series of presses:
winc_presses = 0
return
Thank you for documentation (and promptness!) Here's a working AHK script to have double-tap back-tick send the lozenge character. It took way more time than I want to think about, once started I couldn't let go. ``` ; -={ tick-tick-lozenge.ahk }=- ; Double-tap backtick sends Pollen command character (◊) ; For some reason I needed to use Unicode 'U+25CA' ; instead of the standard alt-code '9674' ; ; Adapted from http://ahkscript.org/docs/commands/SetTimer.htm ; and http://www.autohotkey.com/board/topic/145507-how-to-use-double-tap-backtick-with-pass-through/ ; #EscapeChar \ $`:: if winc_presses > 0 {winc_presses += 1 return } winc_presses = 1 SetTimer, TheKey, 250 ; Wait for more presses, in milliseconds return TheKey: SetTimer, TheKey, off if winc_presses = 1 ; The key was pressed once. {Send ` } else if winc_presses = 2 ; The key was pressed twice. {Send {U+25CA} } ; Regardless of which action above was triggered, reset the count to ; prepare for the next series of presses: winc_presses = 0 return ```
mbutterick commented 10 years ago (Migrated from github.com)

Nice. Is this something I could add to the docs?

On Jul 17, 2015, at 11:12 PM, matt wilkie notifications@github.com wrote:

Thank you for documentation (and promptness!)

Here's a working AHK script to have double-tap back-tick send the lozenge character. It took way more time than I want to think about, once started I couldn't let go.

; -={ tick-tick-lozenge.ahk }=-
; Double-tap backtick sends Pollen command character (◊)
; For some reason I needed to use Unicode 'U+25CA'
; instead of the standard alt-code '9674'
;
; Adapted from http://ahkscript.org/docs/commands/SetTimer.htm
; and http://www.autohotkey.com/board/topic/145507-how-to-use-double-tap-backtick-with-pass-through/
;
#EscapeChar
$`::
if winc_presses > 0
{winc_presses += 1
return
}

winc_presses = 1
SetTimer, TheKey, 250 ; Wait for more presses, in milliseconds
return

TheKey:
SetTimer, TheKey, off
if winc_presses = 1 ; The key was pressed once.
{Send `
}
else if winc_presses = 2 ; The key was pressed twice.
{Send {U+25CA}
}

; Regardless of which action above was triggered, reset the count to
; prepare for the next series of presses:
winc_presses = 0
return

Reply to this email directly or view it on GitHub.

Nice. Is this something I could add to the docs? > On Jul 17, 2015, at 11:12 PM, matt wilkie notifications@github.com wrote: > > Thank you for documentation (and promptness!) > > Here's a working AHK script to have double-tap back-tick send the lozenge character. It took way more time than I want to think about, once started I couldn't let go. > > ; -={ tick-tick-lozenge.ahk }=- > ; Double-tap backtick sends Pollen command character (◊) > ; For some reason I needed to use Unicode 'U+25CA' > ; instead of the standard alt-code '9674' > ; > ; Adapted from http://ahkscript.org/docs/commands/SetTimer.htm > ; and http://www.autohotkey.com/board/topic/145507-how-to-use-double-tap-backtick-with-pass-through/ > ; > #EscapeChar \ > $`:: > if winc_presses > 0 > {winc_presses += 1 > return > } > > winc_presses = 1 > SetTimer, TheKey, 250 ; Wait for more presses, in milliseconds > return > > TheKey: > SetTimer, TheKey, off > if winc_presses = 1 ; The key was pressed once. > {Send ` > } > else if winc_presses = 2 ; The key was pressed twice. > {Send {U+25CA} > } > > ; Regardless of which action above was triggered, reset the count to > ; prepare for the next series of presses: > winc_presses = 0 > return > — > Reply to this email directly or view it on GitHub.
maphew commented 10 years ago (Migrated from github.com)

Yes, certainly. I'm honored to help.

Yes, certainly. I'm honored to help.
rl2999 commented 10 years ago (Migrated from github.com)

Perhaps this is a DrRacket feature addition (of which I know little about), but perhaps you could create a menu item for the lozenge character and bind it to a keypress. I imagine this would be enabled through a Racket package. It could go something like... "Insert > Lozenge"

This probably isn't the answer you wanted, but if you're using Emacs, I tried to write a tiny function that inserts the lozenge character. I chose M-\ because that's the key for the lambda character in DrRacket.

;; Put this in your Emacs .init file:
;; enable lozenge for Pollen
;; ◊◊◊◊◊◊◊◊◊◊◊◊◊
;; 'mule-unicode part from
;; https://lists.gnu.org/archive/html//emacs-devel/2005-03/msg01187.html
(defun insert-lozenge ()
  "inserts the lozenge character for use with Pollen"
  ;; enables function through M-x
  (interactive)
  ;; insert the proper character
  (insert (make-char
           'mule-unicode-2500-33ff 34 42)))
;; Bind key to M-\ a la DrRacket for lambda
(global-set-key "\M-\\" 'insert-lozenge)
Perhaps this is a DrRacket feature addition (of which I know little about), but perhaps you could create a menu item for the lozenge character and bind it to a keypress. I imagine this would be enabled through a Racket package. It could go something like... "Insert > Lozenge" This probably isn't the answer you wanted, but if you're using Emacs, I tried to write a tiny function that inserts the lozenge character. I chose M-\ because that's the key for the lambda character in DrRacket. <pre> ;; Put this in your Emacs .init file: ;; enable lozenge for Pollen ;; ◊◊◊◊◊◊◊◊◊◊◊◊◊ ;; 'mule-unicode part from ;; https://lists.gnu.org/archive/html//emacs-devel/2005-03/msg01187.html (defun insert-lozenge () "inserts the lozenge character for use with Pollen" ;; enables function through M-x (interactive) ;; insert the proper character (insert (make-char 'mule-unicode-2500-33ff 34 42))) ;; Bind key to M-\ a la DrRacket for lambda (global-set-key "\M-\\" 'insert-lozenge)</pre>
interstar commented 9 years ago (Migrated from github.com)

Hmmm ... I found that this lozenge was extremely off-putting to me trying Pollen.

So I'm trying a keybinding. I created a file called keys.rkt

#lang s-exp framework/keybinding-lang

(keybinding "c:<" (λ (editor evt) (send editor insert "◊")))

and loaded it into drracket with Edit>Keybindings>Add user defined keybindings

Now I can use ctrl-shift-< to put the lozenge in.

I'm not a drracket expert so I don't know if it's possible to automatically load this keybinding into #lang pollen though.

Hmmm ... I found that this lozenge was extremely off-putting to me trying Pollen. So I'm trying a keybinding. I created a file called keys.rkt ``` #lang s-exp framework/keybinding-lang (keybinding "c:<" (λ (editor evt) (send editor insert "◊"))) ``` and loaded it into drracket with Edit>Keybindings>Add user defined keybindings Now I can use ctrl-shift-< to put the lozenge in. I'm not a drracket expert so I don't know if it's possible to automatically load this keybinding into #lang pollen though.
mbutterick commented 9 years ago (Migrated from github.com)

You can change the lozenge to anything you want by overriding the command-char for your project. Documented here.

There's a button in the DrRacket toolbar that will insert the lozenge (or whatever the command character is). I don’t think I will impose a specific keybinding since that tends to be more a matter of personal preference.

You can change the lozenge to anything you want by overriding the `command-char` for your project. [Documented here](http://docs.racket-lang.org/pollen/Setup.html#%28part._setup-overrides%29). There's a button in the DrRacket toolbar that will insert the lozenge (or whatever the command character is). I don’t think I will impose a specific keybinding since that tends to be more a matter of personal preference.
interstar commented 9 years ago (Migrated from github.com)

Won't changing to a custom symbol risk breaking copy / pasting between different users' code / books if one prefers not to use the lozenge?

I understand not wanting to impose specific keybinding. But it's maybe worth documenting this for drracket users, just as you're doing for emacs?

regards

Phil

Won't changing to a custom symbol risk breaking copy / pasting between different users' code / books if one prefers not to use the lozenge? I understand not wanting to impose specific keybinding. But it's maybe worth documenting this for drracket users, just as you're doing for emacs? regards Phil
mbutterick commented 9 years ago (Migrated from github.com)

Won't changing to a custom symbol risk breaking copy / pasting between different users' code / books if one prefers not to use the lozenge?

No one has reported that as a problem.

maybe worth documenting this for drracket users, just as you're doing for emacs

I will add it to the list of doc edits.

> Won't changing to a custom symbol risk breaking copy / pasting between different users' code / books if one prefers not to use the lozenge? No one has reported that as a problem. > maybe worth documenting this for drracket users, just as you're doing for emacs I will add it to the list of doc edits.
jbshirk commented 7 years ago (Migrated from github.com)

I'm so glad I finally found this thread. I've been reading Pollen docs for a couple of weeks, but I use a MacBook Pro, so the lozenge issue has been nagging me in a bad way.

I didn't really want to change the default character, as that means whatever I write isn't something that will work out of the box if I share it.

I use a utility called Karabiner to give me the lacking forward delete key (I find that I never use the right-Opt key in practice). The trouble with Karabiner is that it has a bewildering set of capabilities, and even profiles for different applications - but it's hard to understand and I don't see a way to map to an arbitrary character such as lozenge. It also might prove problematic for people who use multiple language keyboard mappings.

There aren't a lot of useless keys left on the MBP, and I didn't like the idea of re-mapping a key, as outside the context of Pollen, it makes that key useless.

What I was hoping to do was use a digraph, such as <>, that automagically converts to a lozenge in my editor - not far from the way Sublime automatically closes "(". This should not happen, of course outside of that context, for example, when writing SQL.

Perhaps there is a way to do this in Dr. Racket.

Or perhaps there is a function that will take a defined command-string "<>" and convert new occurrences and write them as ◊

I'm so glad I finally found this thread. I've been reading Pollen docs for a couple of weeks, but I use a MacBook Pro, so the lozenge issue has been nagging me in a bad way. I didn't really want to change the default character, as that means whatever I write isn't something that will work out of the box if I share it. I use a utility called [Karabiner](https://github.com/tekezo/Karabiner/) to give me the lacking forward delete key (I find that I never use the right-Opt key in practice). The trouble with Karabiner is that it has a [bewildering set of capabilities](https://github.com/tekezo/Files/tree/master/KeyRemap4MacBook), and even profiles for different applications - but it's hard to understand and I don't see a way to map to an arbitrary character such as lozenge. It also might prove problematic for people who use multiple language keyboard mappings. There aren't a lot of useless keys left on the MBP, and I didn't like the idea of re-mapping a key, as outside the context of Pollen, it makes that key useless. What I was hoping to do was use a digraph, such as <>, that automagically converts to a lozenge in my editor - not far from the way Sublime automatically closes "(". This should not happen, of course outside of that context, for example, when writing SQL. Perhaps there is a way to do this in Dr. Racket. Or perhaps there is a function that will take a defined command-_string_ "<>" and convert new occurrences and write them as &#9674;
mbutterick commented 7 years ago (Migrated from github.com)

Please post your question to the Pollen mailing list.

Please post your question to the [Pollen mailing list](https://groups.google.com/forum/#!forum/pollenpub).
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: mbutterick/pollen#73
Loading…
There is no content yet.