I want to redefine keybindings for the commandline of a lisp dialect. The commandline is actually modeled after Vi and implemented with tput/terminfo. I want an alternative version with Emacs keybindings, and I would like to give it a try without using gnu readline or so.

A typical key assignment looks like this:

(setq *XtF1 (in '("tput" "kf1") (line T)) ...

This question is about the

("tput" "kf1")

part, ignore the rest. Now, "kf1" is easy to find in the terminfo man-page:

   key_f1                     kf1     k1    F1 function key

I find there 3 entries for "meta" too:

   has_meta_key               km      km    Has a meta key
                                            (i.e., sets 8th-bit)

   meta_off                   rmm     mo    turn off meta mode
   meta_on                    smm     mm    turn on meta mode
                                            (8th-bit on)

But how can I use this info to define typical Emacs keybindings like e.g. M-f, M-b, M-d etc. with tput?

1 Answer 1


terminfo is probably not going to help you much. In most terminal emulators, you can configure with M-x sends <Esc>x or x with the 8th bit set, and the terminfo entry won't magically be updated when the user does so.

Also, most character sets are 8bits now, so it doesn't make much sense nowadays to use that 8th bit for Meta.

I would just hardcode M-x == <Esc>x (the sequence of two characters \033 and x). This way, even if the terminal doesn't support that mode, the user can still type Esc, x in sequence.

  • Thanks for the answer, I think your last paragraph is the way to go.
    – user17106
    Oct 29, 2012 at 8:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .