Timothy.Freeman@PROOF.ERGO.CS.CMU.EDU (08/10/89)
When I'm using Emacs on a Sun 3 under X11, I would like the keys on the application keypad to send unique escape sequences. This isn't the case for emacs version 18.54, becuase the arrow keys send control codes. For instance, Uparrow (R8) sends a control-p which I cannot distinguish from a real control-p. Assuming that someone really wants the arrow keys to send control characters, I added an optional command line argument to gnu-emacs that makes the arrow keys send the same codes they do on a Sun Console. The diffs are below. You may want to make the change differently; maybe you'll want to call the command line flag something other than "-cck", or maybe you'll want to make the change manditory instead of having a command line argument. Change to src/x11term.c: *** /tmp/geta5006 Tue Aug 8 01:50:12 1989 --- /tmp/getb5006 Tue Aug 8 01:50:14 1989 *************** *** 1,3 **** --- 1,7 ---- + /* This version modified so the -cck option when running Emacs on a + Sun makes the arrow keys behave like they used to. + + Modified - Tim Freeman (tsf@cs.cmu.edu) 7 August 1989 */ /* This version - modified to acknowledge the option "-wn WPE" as a special option which forces the use of the *************** *** 211,216 **** --- 215,226 ---- static char *temp_borderWidth; static char *temp_internalBorder; + #ifdef sun + int ConsoleCompatibleKeyboard; /* Whether to make the arrow keys behave like they do on the console. + If true, they generate escape [ X, for X=A, B, C, D. + If false, they generate control X, for X=n, p, b, f (not necessarily corresponding). */ + #endif + struct _xdeftab { char *iname; /* instance name */ *************** *** 1357,1379 **** nbytes = strlen(mapping_buf); } else { ! switch (keysym) { ! case XK_Left: ! strcpy(mapping_buf,"\002"); ! nbytes = 1; ! break; ! case XK_Right: ! strcpy(mapping_buf,"\006"); ! nbytes = 1; ! break; ! case XK_Up: ! strcpy(mapping_buf,"\020"); ! nbytes = 1; ! break; ! case XK_Down: ! strcpy(mapping_buf,"\016"); ! nbytes = 1; ! break; } } if (nbytes) { --- 1367,1410 ---- nbytes = strlen(mapping_buf); } else { ! if (ConsoleCompatibleKeyboard) { ! switch (keysym) { ! case XK_Left: ! strcpy(mapping_buf,"\033[D"); ! nbytes = 3; ! break; ! case XK_Right: ! strcpy(mapping_buf,"\033[C"); ! nbytes = 3; ! break; ! case XK_Up: ! strcpy(mapping_buf,"\033[A"); ! nbytes = 3; ! break; ! case XK_Down: ! strcpy(mapping_buf,"\033[B"); ! nbytes = 3; ! break; ! } ! } else { ! switch (keysym) { ! case XK_Left: ! strcpy(mapping_buf,"\002"); ! nbytes = 1; ! break; ! case XK_Right: ! strcpy(mapping_buf,"\006"); ! nbytes = 1; ! break; ! case XK_Up: ! strcpy(mapping_buf,"\020"); ! nbytes = 1; ! break; ! case XK_Down: ! strcpy(mapping_buf,"\016"); ! nbytes = 1; ! break; ! } } } if (nbytes) { *************** *** 1536,1541 **** --- 1567,1575 ---- visible_bell = 1; inverse_video = 0; configure_pending = 0; + #ifdef sun + ConsoleCompatibleKeyboard = 0; + #endif fix_screen_hook = xfixscreen; clear_screen_hook = XTclear_screen; *************** *** 1650,1655 **** --- 1684,1696 ---- xxargc--; xxargv++; } + #ifdef sun + if (xxargc && !strcmp (*xxargv, "-cck")) { + ConsoleCompatibleKeyboard = 1; + xxargc--; + xxargv++; + } + #endif if ((xxargc > 1) && (!strcmp (*xxargv, "-font") || !strcmp (*xxargv, "-fn"))) { xxargc--; Changes to lisp/term/x11-win.el. The second change described here was only necessary for us because our .el files and our .c files seem to be from different versions of emacs. You probably will only need to do the first change. *** /tmp/geta5030 Tue Aug 8 01:54:01 1989 --- /tmp/getb5030 Tue Aug 8 01:54:02 1989 *************** *** 19,25 **** ;; and this notice must be preserved on all copies. (setq command-switch-alist ! (append '(("-r" . ignore) ("-i" . ignore) ("-font" . xignore) ("-fn" . xignore) --- 19,26 ---- ;; and this notice must be preserved on all copies. (setq command-switch-alist ! (append '(("-cck" . ignore) ! ("-r" . ignore) ("-i" . ignore) ("-font" . xignore) ("-fn" . xignore) *************** *** 38,44 **** (defun xignore (&rest ignore) (setq command-line-args-left (cdr command-line-args-left))) ! (if (not (null xterm)) (progn (require 'x-mouse) (put 'suspend-emacs 'disabled --- 39,46 ---- (defun xignore (&rest ignore) (setq command-line-args-left (cdr command-line-args-left))) ! ;; Don't know where the variable named "xterm" went to. ! (if t ; (not (null xterm)) (progn (require 'x-mouse) (put 'suspend-emacs 'disabled