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

Escape sequences not parsed from .inputrc #105

Open
camdez opened this issue Oct 17, 2014 · 0 comments
Open

Escape sequences not parsed from .inputrc #105

camdez opened this issue Oct 17, 2014 · 0 comments

Comments

@camdez
Copy link
Contributor

camdez commented Oct 17, 2014

rb-readline will read a user's ~/.inputrc (or /etc/inputrc), like GNU Readline, but when reading keybindings from those files, rb-readline doesn't understand escape sequences. This means that (1) .inputrc files are difficult for rb-readline users to make because they must contain literal versions of control and escape characters, and (2) GNU Readline and rb-readline will interpret the same keystrokes from a single .inputrc file completely differently.

To test this, put basically any binding in your ~/.inputrc file using the textual notation of Readline and you'll see it work in something like Bash and fail under rb-readline. For instance:

"\C-h": "Why, hello there!"

Here's the relevant portion of the GNU Readline man page detailing the escape sequences that should be available in a .inputrc:

"KEYSEQ": FUNCTION-NAME or MACRO
     KEYSEQ differs from KEYNAME above in that strings denoting an
     entire key sequence can be specified, by placing the key
     sequence in double quotes.  Some GNU Emacs style key escapes
     can be used, as in the following example, but the special
     character names are not recognized.

          "\C-u": universal-argument
          "\C-x\C-r": re-read-init-file
          "\e[11~": "Function Key 1"

     In the above example, `C-u' is again bound to the function
     `universal-argument' (just as it was in the first example),
     `C-x C-r' is bound to the function `re-read-init-file', and
     `<ESC> <[> <1> <1> <~>' is bound to insert the text `Function
     Key 1'.


The following GNU Emacs style escape sequences are available when
specifying key sequences:

`\C-'
     control prefix

`\M-'
     meta prefix

`\e'
     an escape character

`\\'
     backslash

`\"'
     <">, a double quotation mark

`\''
     <'>, a single quote or apostrophe

In addition to the GNU Emacs style escape sequences, a second set
of backslash escapes is available:

`\a'
     alert (bell)

`\b'
     backspace

`\d'
     delete

`\f'
     form feed

`\n'
     newline

`\r'
     carriage return

`\t'
     horizontal tab

`\v'
     vertical tab

`\NNN'
     the eight-bit character whose value is the octal value NNN
     (one to three digits)

`\xHH'
     the eight-bit character whose value is the hexadecimal value
     HH (one or two hex digits)

When entering the text of a macro, single or double quotes must be
used to indicate a macro definition.  Unquoted text is assumed to
be a function name.  In the macro body, the backslash escapes
described above are expanded.  Backslash will quote any other
character in the macro text, including `"' and `''.  For example,
the following binding will make `C-x \' insert a single `\' into
the line:
     "\C-x\\": "\\"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant