From: exujsch@exu.ericsson.se (Johnny Schmittou EXU-T-EEG x7887 Dallas Texas USA)
Newsgroups: comp.emacs
Subject: xterm key bindings for jove and GNUEmacs (Part 1)
Keywords: xterm, .Xdefaults, .joverc, .emacs
Date: 27 Aug 92 14:40:55 GMT
Reply-To: exujsch@exu.ericsson.se (Johnny Schmittou EXU-T-EEG x7887 Dallas Texas USA)
Organization: Ericsson Network Systems


In article <1992Aug26.145011.20880@exu.ericsson.se> I wrote:
: --------------------------------------------------------------------------
: Here's a hint.  Use "xterm".  You can re-bind the crap of anything you
: damn well please on the keyboard, w/ all kinds of crazy sequences that
: you'll never be able to remember.  You can do this via the ".Xdefaults"
: file.  IMHO, xterm is *much* more flexible than shelltool or cmdtool as
: an openwindows shell interface.  If you want more info, let me know and
: I can e-mail you some files, etc.
: --------------------------------------------------------------------------

Several people have requested that I make a post re: the above so this
is it.  I will put some of the info in this post and the rest in a 2nd
post.

OK.  Here are the disclaimers.  I'm using a SPARCstation with a SUN4 type
keyboard with a monochrome monitor.  We are running SUN's OpenWindows V2.0.
My key bindings are done thru a combination of the ".Xdefaults" file, the
".joverc" file for use with jove (and I'm using jove V4.9 now), and finally
the ".emacs" file for use with GNUEmacs.  These bindings are intended to be
used only from an "xterm" shell.  THEY WILL NOT WORK FROM A SHELLTOOL OR
CMDTOOL SHELL!

Here's the line that I use to start an "xterm" shell.  I call this typically
from a "shelltool" shell and then I exit the shelltool shell when the
xterm shell becomes alive.

xterm -rv -j -rw -xrm "*pointerShape : top_left_arrow" -sf -geometry 110x45+25+80 #70x70+792+5 -T "Xterm wide" -n Xwide -fn screen.b.16 -iconic -e tcsh   &


Note:  From the above, xterm invocation that I'm having it execute the
"tcsh" program.  If you're running the plain "csh", then change yours
to execute that shell, or whatever other shell you may be running.
Also, note, only issue the above "xterm" once you setup the following
in your ".Xdefaults" file, your ".joverc" file and/or your ".emacs" file.

Once you've got the .Xdefaults, the .joverc and/or the .emacs files
setup, and you've logged off and back on, then when you get your "xterm"
started, issue the command "jove" from the xterm shell to fire up jove,
or "emacs -nw" from the xterm shell to fire up GNUEmacs.  Note the
"-nw" which means "no window".  I use this so that I can keep all my
current "xterm" window attributes and such that GNUEmacs does not
start up a new window (shell).

Here's the info from my .Xdefaults file to rebind the keyboard for use
with an "xterm" shell.

------------- begin cut here for use in .Xdefaults file--------------------
XTerm*Scrollbar:	False
XTerm*VT100.translations:	\
#override  \n\
  Shift<KeyPress>Select:select-cursor-start() select-cursor-end(CLIPBOARD,CUT_BUFFER0,PRIMARY)\n\
        Shift<Key>F1:                   string("cat ~/setup/.fkeys
	<Key>F1:                        string(0x1b) string("1")     \n\
	Shift<Key>F2:                   string("ls -aF
	<Key>F2:                        string(0x1b) string("2")     \n\
	Shift<Key>F3:                   string("exit")               \n\
	<Key>F3:                        string(0x1b) string("3")     \n\
	Shift<Key>F4:                   string("mail
	<Key>F4:                        string(0x1b) string("4")     \n\
	Shift<Key>F5:                   string("rusers
	<Key>F5:                        string(0x1b) string("5")     \n\
	Shift<Key>F6:                   string("/home/exuxtde/bin/sun4/q
	<Key>F6:                        string(0x1b) string("6")     \n\
	Shift<Key>F7:                   string("ftp rchn
	<Key>F7:                        string(0x1b) string("7")     \n\
	Shift<Key>F8:                   string("ps -aux
	<Key>F8:                        string(0x1b) string("8")     \n\
	Shift<Key>F9:                   string("alias|more
	<Key>F9:                        string(0x1b) string("9")     \n\
	Shift<Key>F10:                  string("ls -laF")            \n\
	<Key>F10:                       string(0x1b) string("0")     \n\
 	Shift<Key>SunF36:               string("lpq
 	<Key>SunF36:                    string(0x18) string("1")     \n\
 	Shift<Key>SunF37:               string("lock
 	<Key>SunF37:                    string(0x18) string("2")     \n\
   	Any<Key>KP_Equal:               string(0x1b) string("h")     \n\
 	Shift<Key>KP_Divide:            string(0x1c)                 \n\
 	   <Key>KP_Divide:              string(0x12)                 \n\
 	Shift<Key>KP_Multiply:          string(0x1b) string("s")     \n\
 	   <Key>KP_Multiply:            string(0x13)                 \n\
 	Shift<Key>KP_Subtract:          string(0x19)                 \n\
 	   <Key>KP_Subtract:            string(0x18) string("-")     \n\
 	Shift<Key>KP_7:                 string(0x18) string("W")     \n\
 	   <Key>KP_7:                   string(0x18) string(0x17)    \n\
 	Shift<Key>KP_8:                 string(0x18) string("A")     \n\
 	Ctrl<Key>KP_8:                  string(0x1b) string("{")     \n\
 	Meta<Key>KP_8:                  string(0x18) string("A")     \n\
 	   <Key>KP_8:                   string(0x1b) string("[A")    \n\
 	Shift<Key>KP_9:                 string(0x18) string("L")     \n\
 	   <Key>KP_9:                   string(0x18) string(0x0c)    \n\
 	Shift<Key>KP_4:                 string(0x18) string("D")     \n\
 	Ctrl<Key>KP_4:                  string(0x08)                 \n\
 	Meta<Key>KP_4:                  string(0x18) string("D")     \n\
 	   <Key>KP_4:                   string(0x1b) string("[D")    \n\
 	Any<Key>KP_5:                   string(0x1b) string("[218z") \n\
 	Shift<Key>KP_6:                 string(0x18) string("C")     \n\
 	Ctrl<Key>KP_6:                  string(0x06)                 \n\
 	Meta<Key>KP_6:                  string(0x18) string("C")     \n\
 	   <Key>KP_6:                   string(0x1b) string("[C")    \n\
 	Shift<Key>KP_1:                 string(0x1b) string("L")     \n\
 	   <Key>KP_1:                   string(0x18) string("E")     \n\
 	Shift<Key>KP_2:                 string(0x18) string("B")     \n\
 	Ctrl<Key>KP_2:                  string(0x1b) string("}")     \n\
 	Meta<Key>KP_2:                  string(0x18) string("B")     \n\
 	   <Key>KP_2:                   string(0x1b) string("[B")    \n\
 	Shift<Key>KP_3:                 string(0x1b) string("U")     \n\
 	   <Key>KP_3:                   string(0x06)                 \n\
 	Shift<Key>KP_0:                 string(0x0f)                 \n\
 	   <Key>KP_0:                   string(0x01)                 \n\
 	Shift<Key>KP_Decimal:           string(0x18) string(".")     \n\
 	   <Key>KP_Decimal:             string(0x1b) string(".")     \n\
 	Shift<Key>KP_Enter:             string(0x18) string("7")     \n\
 	   <Key>KP_Enter:               string(0x18) string("6")     \n\
 	Shift<Key>KP_Add:               string(0x19)                 \n\
 	   <Key>KP_Add:                 string(0x18) string("+")     \n\
        Shift<Key>Mode_switch:          string(0x18) string("l")     \n\
           <Key>Mode_switch:            string(0x18) string("w")     \n\
  Shift<Key>Delete:                     string(0x04)                 \n\
     <Key>Delete:                       string(0x7f)                 \n\
  Any<Key>BackSpace:                    string(0x08)                 \n\
  Shift<Key>R1:                         string(0x18) string("4")     \n\
     <Key>R1:                           string(0x18) string("3")     \n\
  Shift<Key>R2:                         string(0x18) string("9")     \n\
     <Key>R2:                           string(0x17)                 \n\
  Shift<Key>R3:                         string(0x18) string("8")     \n\
     <Key>R3:                           string(0x19)                 \n\
  Any<Key>L1:                           string(0x1b) string("z")     \n\
  Any<Key>L3:                           string(0x18) string("a")     \n\
  Any<Key>L6:  start-extend() select-end(PRIMARY, CLIPBOARD, CUT_BUFFER0) \n\
  Any<Key>L8:  insert-selection(CLIPBOARD) \n\
  Any<Key>L9:                           string(0x1b) string("a")           \n
XTerm*boldFont:	screen.b.16
XTerm*font:	screen.r.16
XTerm*reverseVideo:	True
XTerm*saveUnder:	False
XTerm*sunFunctionKeys:	True
XTerm*termName:	xterm
XTerm*ttyModes:	intr ^c erase ^h kill ^u
:	
------------- end cut here for use in .Xdefaults file--------------------

To find out what a particular key is named for use in the above, start up
the "xev" program from an xterm shell and then type the key in question.
You'll get a couple of lines of info and you'll see the key's name, e.g.
"F31" in there somewhere.

Following is the .joverc file I use which binds jove functions to the
key sequences that I defined above:

------------- begin cut here for .joverc file, jove V4.9 --------------------
set case-ignore-search ON
set match-regular-expressions ON
#---------------------------------------------------
# Binding for the arrow keys
#---------------------------------------------------
#bind-to-key ansi-codes ^[[
#bind-to-key previous-line ^[[A
#bind-to-key next-line ^[[B
#bind-to-key forward-character ^[[C
#bind-to-key backward-character ^[[D
#---------------------------------------------------
# Binding for the control keys
#---------------------------------------------------
bind-to-key over-write-mode ^A
bind-to-key beginning-of-line ^B
bind-to-key forward-word ^F
bind-to-key backward-word ^H
bind-to-key next-page ^N
bind-to-key previous-page ^P
bind-to-key visit-file ^V
bind-to-key exit-jove ^Z
bind-to-key delete-previous-character ^?
bind-to-key search-forward ^_
bind-to-key search-reverse ^\
#---------------------------------------------------
# Binding for the escape keys
#---------------------------------------------------
bind-to-key execute-kbd-macro ^[/
bind-to-key beginning-of-file ^[b
bind-to-key case-word-capitalize ^[c
bind-to-key end-of-file ^[e
bind-to-key find-file ^[i
bind-to-key bind-to-key ^[k
bind-to-key next-window ^[n
bind-to-key write-file ^[o
bind-to-key previous-window ^[p
bind-to-key search-forward ^[s
bind-to-key exit-jove ^[z
bind-to-key beginning-of-file ^[B
bind-to-key case-word-capitalize ^[C
bind-to-key end-of-file ^[E
bind-to-key describe-command ^[H
bind-to-key find-file ^[I
bind-to-key bind-to-key ^[K
bind-to-key next-window ^[N
bind-to-key write-file ^[O
bind-to-key previous-window ^[P
bind-to-key search-forward ^[S
bind-to-key exit-jove ^[Z
bind-to-key set-mark ^[.
bind-to-key beginning-of-window ^[{
bind-to-key end-of-window ^[}
#---------------------------------------------------
# Binding for the function keys F1-F12 for Sun4 kbd
# Note: The normal key mappings for these keys have 
# been changed via the .Xdefaults file.
#---------------------------------------------------
bind-to-key delete-other-windows ^[1
bind-to-key split-current-window ^[2
bind-to-key write-file ^[3
bind-to-key find-file ^[4
bind-to-key query-replace ^[5
bind-to-key list-buffers ^[6
bind-to-key previous-page ^[7
bind-to-key next-page ^[8
bind-to-key delete-buffer ^[9
bind-to-key describe-key ^[0
bind-to-key describe-command ^X1
bind-to-key select-buffer ^X2
#---------------------------------------------------
# Binding for some of the righthand and lefthand
# keypad keys for Sun4 kbd.
# Note: The normal key mappings for these keys have 
# been changed via the .Xdefaults file.
#---------------------------------------------------
bind-to-key execute-named-command ^X3
bind-to-key shell-command ^X4
bind-to-key kill-next-word ^X+
bind-to-key grow-window ^X6
bind-to-key shrink-window ^X7
bind-to-key apropos ^Xa
bind-to-key kill-to-end-of-line ^X.
bind-to-key beginning-of-file ^XA
bind-to-key beginning-of-line ^XD
bind-to-key end-of-line ^XC
bind-to-key end-of-file ^XB
bind-to-key backward-word ^XE
#---------------------------------------------------
# Define macros
#---------------------------------------------------
# define-macro copy-above-space ^[[A^[.^F^H^W^Y^[[B^Y
# define-macro copy-below-space ^[[B^[.^F^H^W^Y^[[A^Y
define-macro copy-above-word ^[[A^[.^F^W^Y^[[B^Y
define-macro copy-above-line ^[[A^[.^E^W^Y^[[B^Y
define-macro copy-below-word ^[[B^[.^F^W^Y^B^[[A^E^Y
define-macro copy-below-line ^[[B^[.^E^W^Y^[[A^Y
define-macro copy-above-space ^[[A^[.^F^H^W^Y^X^X^[[B^Y
define-macro copy-below-space ^[[B^[.^F^H^W^Y^X^X^[[A^Y
define-macro fndnxt ^_^M
define-macro fndprev ^\^M
define-macro insert-4-spaces     
define-macro movetest ^[itest.script^M^[2^[isgaedati.script^M^_jbs m^M^[[218z^[.^[e^W^Y^[[218z^B^Y
define-macro auto-get-file ^K^Y^[[C^[i^Y^M
define-macro trim-trailing-asterisk ^_\\*^M^[.^[[214z^[[216z^W
define-macro trim-leading-asterisk ^_* ^M^[.^B^W
define-macro fix-xtphone-list   ^[[C^[[C^[[C^[[C^[[C  ^[[C^[[C^[[C^[[C^[[C^[[C  ^[[B^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D^[[D
define-macro comment-out-np ^S^B.* ^E
define-macro remove-trailing-blanks ^E^[[214z^[[216z^[[C^K^M
define-macro insert-blank-comment ^B^M^[[A                                                        !                                          !^B^[[B
define-macro ins-jbs-comm ^M^[[A!----------------- jbs ----------------------------------------------------------------------------!^B^[[B
define-macro delete-line ^K^K
define-macro insert-us :us.^[s ^M^[[D:eus.
define-macro help-keypad ^[1^[2^[4/home/exujsch/setup/keypad.txt^M^[[218z
define-macro fix-tr-listing ^_\^1^M^B^Q^L^K^B^[[B^K^K
define-macro fix-manhours ^X.^M^[[D^[[B
define-macro abort ^G
#---------------------------------------------------
# Bind the above macro definitions to keys
#---------------------------------------------------
#bind-macro-to-key insert-4-spaces ^I
bind-macro-to-key fndprev ^R
bind-macro-to-key fndnxt ^S
bind-macro-to-key copy-above-word ^X^W
bind-macro-to-key copy-below-word ^XW
bind-macro-to-key copy-above-line ^X^L
bind-macro-to-key copy-below-line ^XL
bind-macro-to-key copy-above-space ^Xw
bind-macro-to-key copy-below-space ^Xl
bind-macro-to-key auto-get-file ^[A
bind-macro-to-key auto-get-file ^[a
bind-macro-to-key insert-blank-comment ^[=
bind-macro-to-key ins-jbs-comm ^['
bind-macro-to-key delete-line ^X-
bind-macro-to-key insert-us ^[;
bind-macro-to-key help-keypad ^[h
bind-macro-to-key abort ^X8
bind-macro-to-key abort ^X9
------------- end cut here for .joverc file, jove V4.9 --------------------

The GNUemacs key bindings for use in the .emacs file, will follow this
posting.

Enjoy,
--
___________________________________________________________________________
Internet....: exujsch@exu.ericsson.se | "Everything I say is the absolute
Real life...: Johnny Schmittou        |  Gospel...  Nah, just kidding."
Virtual life: Q-man   ---<<<I'd rather be drumming.>>>--- Dallas, Texas USA