vigna/ne

"0x" prefix "tolerated" in ~/.ne/.keys file

uvtc opened this issue · 5 comments

uvtc commented

Ah ha! Regarding my ~/.ne/.keys file: somehow, I managed to miss the line in the key binding docs where it says:

"You can write just the hexadecimal digits, nothing else is necessary (but a prefixing ‘0x’ is tolerated)."

While I can see that this is very slightly more convenient because I don't have to type the "0x" prefix, I found that it caused me confusion over the years. In every other case, when I see 16 it means 16, but in the ~/.ne/.keys file 16 means 22!

The kc command displays the keycode in hex with the "0x" prefix. When I supply a number to the kc command I can either supply it in decimal (no prefix) or in hex (with the "0x" prefix).

And every programming language I know reads 0x16 as 22, and 16 as 16. :)

I think it would help newcomers become more quickly acclimated to ne if the default.keys file here in the repo had the "0x" prefixes. Would you accept a PR if I went and added the "0x" 's in default.keys as well as in that page of the docs?

In hindsight this was probably a mistake. At first glance I done see a way of fixing this without breaking existing .keys files. While adding the 0x prefix shouldn't hurt, I'd like to think about this before jumping at a partial solution. Perhaps there's a way to indicate a default radix... It's been this way a long time. Let's slow-walk this to make sure we don't preclude a better solution with a quick one.

uvtc commented

I think a good thing to have for now is a comment at the top of default.keys like:

# Note that the keycode numbers in this file are hex values,
# but as a special case for this file, the "0x" prefixes here
# are optional and omitted.

That would've helped me avoid some confusion.

I slightly modified your note and added it to default.keys in the paste-sets-bookmarks branch. We'll probably merge this to master soon, but I want to give the bugs a chance to breed.

# Note: the keycode numbers in this file are case-insensitive hexadecimal
# values as reported by the KeyCode command. The "0x" prefixes are
# optional and omitted. Valid range is from 0 to 1FF.
uvtc commented

Great. Thanks!

Will close this after the merge.

uvtc commented

Sorry -- saw that this was merged back in July with deb8342 . Closing.