Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
Thanks for the answer, I think your last paragraph is the way to go. –  user17106 Oct 29 '12 at 8:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.