[comp.emacs] Function Keys

leake@cme-durer.ARPA (Stephe Leake) (05/09/88)

I support (mostly) Paul Davis's comments on function keys. I started
using Gnuemacs after learning LSE on a VT220, and my fingers "know"
where the editing functions are. In fact, I customized the keypad to
add more functionality (the edit keys on a VT220 replace some of the
EDT standard keypad functions, so I removed the redundancy). It took
awhile, but my gnuemacs is now customized to work the same (well,
mostly) as the LSE. I save by not getting my fingers confused every
time I change systems (which I do twice a week).

In the controversy of `C-M-cokebottle-ESC-c C-x g' vs F1, I lean
towards F1. I think this is because I am spatially oriented as opposed
to time-oriented; it is easier for me to think "cut" and do "finger to
up-left" than to think "cut" and do "this key, that key, the other
key". This is a personal preference, one not shared by everyone.

As for the process of binding function keys, I simply created a file
(global-keys.el) that contains bindings for _all_ the function keys,
initially all to 'undefined. I use define-key - it seems to be the
most straight-forward (and best documented) of the various binding
techniques. Each line ends with a comment labeling the key it defines.
Creating the file is somewhat tedious, but if it had been included in
/term, it would have been trivial. (Maybe someone could act on this
suggestion?). The files that are currently in /term are less easy to
understand and/or modify, since they typically do more than just bind
keys, and they additionally try to define some 'standard bindings'.

I vote for the VT220 keyboard as a 'standard'; it seems to be copied
by other vendors alot, and it has an adequate number of function keys.
Actually, I like the Microterm version slightly better; they put '<'
and '>' back where they belong.

Happy hacking!
-- 
NAME:   Stephe Leake                    TELE: (301) 975-3431
USMAIL: National Bureau of Standards    ARPA: leake@cme-durer.arpa
        Rm. B-124, Bldg. 220            UUCP: uunet!cme-durer!leake
        Gaithersburg, MD  20899

aglew@urbsdc.Urbana.Gould.COM (05/12/88)

Another spatially oriented keyboarder.

Here is my customization file for a Datamedia XL 60, termcap D5
In it I first link the escape sequences generated by keys
to symbolic names (and null functions) for the keys;
and then link these "keyboard specific" names
to a higher level of abstraction, the 3 by 4 keypad,
which I have defined on a number of terminals.
Elsewhere, I have a standard mapping of 3 by 4 keypads to commands.
 
<<<<<A file containing some miscellaneous functions>>>>>>
;; Macro to create a symbolic name for the sequence of characters produced
;; by a key, and to bind it to a usually undefined function of the same
;; name, so that pressing it gives you a message like tvi9220-key-HELP
;; not defined.
(defmacro make-key (key str)
  (list 'progn
    (list 'setq key str)
    (list 'make-global-binding str (list 'quote key))))

<<<<<<The actual terminal file>>>>>>
;;;; AG GNU Emacs customization for Datamedia keyboard terminal type
;; Is almost exactly the same as that for the tvi9220, with fewer keys

(load "gnuterm/make-key")

; MISCELLANEOUS EDITING KEYS
(make-key datamedia-key-TAB "\^i")	    	;standard
; BACK-TAB, INSERT-LINE, DELETE-LINE, CHAR-INSERT, EDIT, CLR,
; DELETE-CHAR, and ENTER are on numeric keypad.


;; PF keys, upper row of keypad.
;; Usually used in the key-3x4 arrangement of cursor keys
(make-key datamedia-keypad-PF1 "\eOP")
(make-key datamedia-keypad-PF2 "\eOQ")
(make-key datamedia-keypad-PF3 "\eOR")
(make-key datamedia-keypad-PF4 "\eOS")
(make-key datamedia-keypad-PF5 "\eot")
(make-key datamedia-keypad-PF6 "\eou")
(make-key datamedia-keypad-PF7 "\eov")
(make-key datamedia-keypad-PF8 "\eow")
(make-key datamedia-keypad-PF9 "\eox")
(make-key datamedia-keypad-PF10 "\eoy")
(make-key datamedia-keypad-PF11 "\eoz")
(make-key datamedia-keypad-PF12 "\eo\\")

;; CURSOR keys, not on the keypad, arranged 	    UP DN L R
; Most often in application mode.

(make-key datamedia-key-normal-cursor-up "\e[A")
(make-key datamedia-key-normal-cursor-down "\e[B")
(make-key datamedia-key-normal-cursor-right "\e[C")
(make-key datamedia-key-normal-cursor-left "\e[D")

; Cursor keys can be shifted
; I am unlikely to want to use these for anything
; because they conflict with existing Emacs ESC commands
(make-key datamedia-key-normal-shifted-cursor-up "\eM")
(make-key datamedia-key-normal-shifted-cursor-down "\eD")
(make-key datamedia-key-normal-shifted-cursor-right "\e[E")
(make-key datamedia-key-normal-shifted-cursor-left "\e[F")

; Application mode cursor keys
(make-key datamedia-key-application-cursor-up "\eOA")
(make-key datamedia-key-application-cursor-down "\eOB")
(make-key datamedia-key-application-cursor-right "\eOC")
(make-key datamedia-key-application-cursor-left "\eOD")

;; KEYPAD keys - labeled as a numeric keypad,
;; but I wish to use their application codes,
;; even though ESC O ... is a loss.
(make-key datamedia-keypad-0 "\eOp")
(make-key datamedia-keypad-1 "\eOq")
(make-key datamedia-keypad-2 "\eOr")
(make-key datamedia-keypad-3 "\eOs")
(make-key datamedia-keypad-4 "\eOt")
(make-key datamedia-keypad-5 "\eOu")
(make-key datamedia-keypad-6 "\eOv")
(make-key datamedia-keypad-7 "\eOw")
(make-key datamedia-keypad-8 "\eOx")
(make-key datamedia-keypad-9 "\eOy")
(make-key datamedia-keypad-- "\eOm")
(make-key datamedia-keypad-COMMA "\eOl")
(make-key datamedia-keypad-DOT "\eOn")
(make-key datamedia-keypad-ENTER "\eOM")

;; FUNCTION keys
;; The datamedia supports both shifted and unshifted function keys F6-F20
;; but, only the unshifted ones have codes assigned by default
(make-key datamedia-key-F1 "\eO'")
(make-key datamedia-key-F2 "\eOa")
(make-key datamedia-key-F3 "\eOb")
(make-key datamedia-key-F4 "\eOc")
(make-key datamedia-key-F5 "\eOd")
(make-key datamedia-key-F6 "\eOe")
(make-key datamedia-key-F7 "\eOf")
(make-key datamedia-key-F8 "\eOg")
(make-key datamedia-key-F9 "\eOh")
(make-key datamedia-key-F10 "\eOi")
(make-key datamedia-key-F11 "\eOj")
(make-key datamedia-key-F12 "\eOk")
(make-key datamedia-key-F13 "\eOl")
(make-key datamedia-key-F14 "\eOm")
(make-key datamedia-key-F15 "\eOn")

;; SCREEN WIDTH
; I like toggling between 80 and 132 characters, depending on my eyestrain.
(setq datamedia-command-80 "\e[?3l")
(setq datamedia-command-132 "\e[?3h")
(defun datamedia-set-screen-width (n)
    "change screen width (80/132)"
    (interactive "NScreen width (80/132): ")
    (cond
	((= n 132)
	    (set-screen-width 132)
	    (send-string-to-terminal datamedia-command-132))
	((= n 80)
	    (set-screen-width 80)
	    (send-string-to-terminal datamedia-command-80))
	(t (message "80/132 screen widths only knowm, not %d" n)))
    (redraw-display))


(defun toggle-screen-width ()
    "toggle screen width between the various possibilities, typically 80/132"
    (interactive)
    (cond
	((= (screen-width) 80) (datamedia-set-screen-width 132))
	(t (datamedia-set-screen-width 80))))
(make-global-binding datamedia-keypad-ENTER 'toggle-screen-width)


;; INITIALIZE
;; Terminal dependent
(defun datamedia-initialize ()
    "initialize a DATAMEDIA for AG's GNU emacs"
    (interactive)
    (mapcar 'send-string-to-terminal
    	(list
	    "\e[?1l"	    ; Normal cursor keys ( ESC [ ... )
	    	    	    ; not application cursor keys
	    "\e="	    	    ; Application keypad mode ( ESC O ... )
	    )
	)
    ;(datamedia-load-function-keys)
    (datamedia-set-screen-width 80)
    )

;; Actually invoke the initialization function
(datamedia-initialize)

 

;; STANDARD KEY ABSTRACTIONS

; PF1  PF2  PF3  PF4
; 7    8    9    -
; 4    5    6    '
; 3 down by 4 across keypad
; superimposed on PF keys
(defun datamedia-3x4-lower ()
    (setq key-3x4-downLeft datamedia-keypad-4)
    (setq key-3x4-downleft datamedia-keypad-5)
    (setq key-3x4-down datamedia-keypad-6)
    (setq key-3x4-downRight datamedia-keypad-COMMA)
    (setq key-3x4-Left datamedia-keypad-7)
    (setq key-3x4-left datamedia-keypad-8)
    (setq key-3x4-right datamedia-keypad-9)
    (setq key-3x4-Right datamedia-keypad--)
    (setq key-3x4-upLeft datamedia-keypad-PF1)
    (setq key-3x4-upleft datamedia-keypad-PF2)
    (setq key-3x4-up datamedia-keypad-PF3)
    (setq key-3x4-upRight datamedia-keypad-PF4))
(datamedia-3x4-lower)

(defun datamedia-arrow-keys ()
    (setq key-arrow-down datamedia-key-application-cursor-down)
    (setq key-arrow-up datamedia-key-application-cursor-up)
    (setq key-arrow-left datamedia-key-application-cursor-left)
    (setq key-arrow-right datamedia-key-application-cursor-right))
(datamedia-arrow-keys)

wdr@cstowe.csoft.co.nz (Bill) (05/17/88)

Hi there fellow emacs devotees,

    On the subject of function keys :

   I never use function keys as they are a major pain when you have to
use many different types of terminals as you travel around the
countryside visiting customers that don't have the good sense to buy
the same terminal you know and love so well back at work. I also don't
use the arrow keys for the same reason. SO THERE!!!! :-)


-------
Give me a E, Give me a M, Give me a A, Give me a C, Give me a S, ------
  EEEEEEMMMMMAAAAAACCCSSSSS -- YAY YAY CHEER CHEER
-------
Disclaimer: Who Cares Anyway
-------
Bill D. Ryder                        ...!uunet!vuwcomp!dsiramd!pnamd!cstowe!wdr
Phone 063-65955 (IDD 64)         or  wdr@csoft.co.nz
Commercial Software N.Z. Ltd., PO Box 4030                                     
Palmerston North,  Aotearoa (New Zealand if want to use snail mail)