Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!comp.vuw.ac.nz!nickson From: nickson@comp.vuw.ac.nz (Ray Nickson) Newsgroups: gnu.bash.bug Subject: Re: Novice question on binding keys Message-ID: <8909130438.AA23567@comp.vuw.ac.nz> Date: 13 Sep 89 04:36:28 GMT References: Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 96 From: Martin Farach Date: 9 Sep 89 18:01:00 GMT Sorry for posting this message on a newsgroup that is set up for bug reporting but I didn't know where else to post. Hey, don't worry, the rest of us do it all the time. I use tcsh and have my arrow keys set to do the expected things. [ ... ] Is there a way to get the desired behaviour? [ ... ] No, not with the current version. Also, can user defined functions be bound to keys? Finally, can key bindings be changed on the fly rather than by changing .inputrc and then starting up a new bash? Ditto. However, I've been doing some hacking... :-) The version I'm using has hacks in it to do the following: - readline reads .keymaprc in $HOME (or file specified in KEYMAPRC); this contains lines of the form bind unbind mbind clear include is a sequence of characters, with the following special interpretations: \C- control \M- meta \F- lookup termcap; eg. \F-ku represents the up-arrow key is the name of a function (previous-line etc) is a sequence of characters to dispatch on is the name of a file to include - bind, unbind are new shell builtins, for changing bindings on the fly - extra readline functions: signal-{stop, quit, interrupt} - send signals redraw-line - tidy up messy displays yank-previous-nth-arg - pull words down from history I have sent my readline hacks to Brian. The code I have written works in the limited environments I have tried it, but is not at all well-written, and is certainly not portable, so I'd rather not generally distribute it. I also haven't got around to slotting it into 1.03, so it still exists only as 1.02 patches. Anyone care to comment on the value of these ideas? /* readline.c -- a general facility for reading lines of input with emacs style editing and completion. */ /* * This version of readline has been massively modified by rgn, Ray * Nickson, nickson@comp.vuw.ac.nz. It is based on the version of * readline distributed with bash-1.02. It differs from standard readline * in the following ways: * 1. I allow keymaps within keymaps; for example, the keymap entry for * control-X can itself be a keymap, so the user can bind a function * to control-X control-A. * 2. I think we should give readline complete control of the * keyboard. To this end, I save the UNIX terminal driver special * characters (the tchars, like ERASE, SUSP etc) before going into * readline, remove their special meaning, and then restore tham * on exit. To achieve the old behaviour, I supply the readline * functions `signal-interrupt', `signal-stop' and `signal-quit', * which the user binds to the keys of her choice. * 3. I've massively changed the format of (and renamed) the startup * file (was ~/.inputrc). Read the comment before the * `rl_read_init_file' for details. I'll supply an * emacs-lisp program to convert an inputrc to a keymaprc. * Important extensions allow binding to key sequences (instead of * just single keystrokes), and the use of termcap names for * function keys. * 4. I advertise a function to allow readline's caller to * interactively change bindings, without knowing about readline's * internal structure. * 5. Limited `macro' facility; `mbind keyseq string' in the keymaprc * causes readline to dispatch on the characters in string when * keyseq is typed. I advertise a function to the caller for * interactively doing macro binds. * 6. It should be possible to add a facility for binding to things * that have meaning to readline's caller, but not to readline * itself (such as shell functions) more easily than is the case * with standard readline. * 7. I haven't done vi mode; I don't think it would be excessively * hard to do. * 8. I haven't tried to make it work with terminfo; what I have * done has been tried only on systems with termcap or termcap * emulation. */ -- Ray Nickson, Dept. Comp. Sci., Victoria University of Wellington, New Zealand. nickson@comp.vuw.ac.nz ...!uunet!vuwcomp!nickson + 64 4 721000x8593