Article View: gnu.epoch.misc
Article #1627Re: Epoch and Sun 4 keyboards
From: Alan M. Carroll
Date: Tue, 21 Jan 1992 15:46
Date: Tue, 21 Jan 1992 15:46
445 lines
19367 bytes
19367 bytes
I've been getting email about this, so I will repost some stuff that
was sent in by other contributors. IMHO these are better than my
stuff, but inertia keeps me from upgrading :-). I haven't actually
tried these, so use at your own risk, as always.
++ From: Richard L. Ford <rlford@maxzilla.encore.com>
I also use epoch::rebind-key to bind keysyms to special sequences, and
then bind based on those sequences, using the code at the end of this
mail. The scheme below was based on some stuff I got elsewhere (I
don't remember who from [my keys.el - AMC]). My main modification was
to change the scheme so that it is based on lists, two for modifiers
of interest (modifier-mask-list and modifier-prefix-list), and one to
give the association between keysym names and the part of the special
sequence after the prefix (sym-id-list). This latter would need to be
changed for terminals with different keysym names.
I keep the modifier prefixes to 0 or 1 characters, for faster dispatching.
The sequences sent for a key are 4 characters at most (e.g. C-^mk0).
The restriction to avoid the modifier-prefix-list characters in the cdrs in
the sym-id-list could be lifted by using a single-character prefix for the
null modifier (e.g. "n" for normal). This would make the "normal" function
key sequences one longer, but would make the modifier prefixes uniformly 1
character long.
When I actually do the binding, I do it with the following auxiliary function:
(defun global-set-^key (modkeyid fun)
(global-set-key (concat "\C-^" modkeyid) fun))
which is used as in the following:
(global-set-^key "k0" 'undo)
(global-set-^key "sk0" 'zap-line)
The scheme on which this was based did not have rebindings for all of the 8
possible modifier combinations. When I started doing that, things got
cumbersome, and that was when I decided that doing it systematically in a loop
would be advantageous.
Rich
------------------------------------------------------------
[Here is the code I use for rebinding]
;;;
;;; This file does keysym rebindings for an ncd xterminal.
;;;
;; Function key mapping is to start with \C-^ as the first character.
;; This seems to not be used in the standard key maps and does
;; not cause problem during a search or in minibuffer.
;; Conventions: All rebound keys send control-^ first, followed by
;; a prefix denoting modifiers, followed by the "keyid" for the
;; key itself.
;;
;; For no modifier, the prefix is empty.
;; letter c is added for control keys, s for shifted keys,
;; m for Meta, C for Control-Shift, and M for Meta-Shift,
;; b for both Control and Meta, and B for Control-Meta-Shift.
;; [Note by rlf: The following warnings are not a problem as long as
;; we only rebind function keys, the key-pad, or insert.. and
;; arrow blocks, as the keysyms for these are not affected by
;; shift. ]
;; Warning - This rebinding depends on using xmodmap to switch keysyms.
;; Warning - What happens normally is that shift states cause the base
;; Warning - keysym to change. The modmap that I use forces the base keysyms
;; Warning - to be stable regardless of the shift state. The modmap is included
;; Warning - at the end of this file.
;;
;; special keys
;We will Bind each of the function keys with eight combinations of
; modifiers: none, shift, meta, control, meta-shift, control-shift,
; control-meta, control-shift-meta.
(setq modifier-mask-list
(list 0 'shift 'meta 'control
'(meta shift) '(control shift) '(control meta) '(control shift meta)))
(setq modifier-prefix-list '("" "s" "m" "c" "M" "C" "b" "B"))
;;The following list gives the correspondence between keysyms and
;; our keyids. Note that none of the keyids should start with a
;; prefix letter (i.e. a letter in modifier-prefix-list).
(setq sym-id-list
'( ("KP_0" . "k0") ;;keypad
("KP_1" . "k1")
("KP_2" . "k2")
("KP_3" . "k3")
("KP_4" . "k4")
("KP_5" . "k5")
("KP_6" . "k6")
("KP_7" . "k7")
("KP_8" . "k8")
("KP_9" . "k9")
("KP_Decimal" . "k.")
("KP_Divide" . "k/")
("KP_Multiply" . "k*")
("KP_Subtract" . "k-")
("KP_Add" . "k+")
("KP_Enter" . "kE")
("Insert" . "i")
;("Delete" . "d")
("Home" . "h")
("End" . "e")
("Prior" . "p") ;;Page Up
("Next" . "n") ;;Page Down
("Up" . "U")
("Left" . "L")
("Right" . "R")
("Down" . "D")
("F1" . "f1")
("F2" . "f2")
("F3" . "f3")
("F4" . "f4")
("F5" . "f5")
("F6" . "f6")
("F7" . "f7")
("F8" . "f8")
("F9" . "f9")
("F10" . "F0")
("F11" . "F1")
("F12" . "F2")
)
)
;Function to rebind keysym with modifiers.
(defun rebind-keysym (keysym keyid)
(let (mask masklist pfx pfxlist)
(setq masklist modifier-mask-list)
(setq pfxlist modifier-prefix-list)
(while masklist
(setq mask (car masklist))
(setq pfx (car pfxlist))
(setq masklist (cdr masklist))
(setq pfxlist (cdr pfxlist))
(epoch::rebind-key keysym mask (concat "\C-^" pfx keyid))
)
)
)
;;Do rebinding for all keysyms in above list.
(let (symidlist keysym keyid)
(setq symidlist sym-id-list)
(while symidlist
(setq keysym (car (car symidlist)))
(setq keyid (cdr (car symidlist)))
(setq symidlist (cdr symidlist))
(rebind-keysym keysym keyid)
)
)
++ From: rand@hwcae.cfsat.honeywell.com (Douglas K. Rand)
If anybody is interested, I wrote a small piece of Lisp code that
allows you to use the X name for a key in your bindings. First I
created a list of the X name of a key, and a number.
(defvar *xemacs-keys*
'(("Select" . 129)
("Insert" . 129)
.....))
Then I made a list of the prefixes I might want to use.
(defvar *xemacs-modifiers*
'((shift . (129 . xemacs-prefix-shift))
(lock . (130 . xemacs-prefix-lock))
(control . (131 . xemacs-prefix-control))
(meta . (132 . xemacs-prefix-meta))
(mod1 . (133 . xemacs-prefix-mod1))
(mod2 . (134 . xemacs-prefix-mod2))
(mod3 . (135 . xemacs-prefix-mod3))
(mod4 . (136 . xemacs-prefix-mod4))
(mod5 . (137 . xemacs-prefix-mod5))
(nil . (138 . xemacs-prefix-normal))))
And finally a prefix string.
(setq xemacs-prefix-string "\C-^")
My lisp function than remaps the key Insert to be the string
"\C-^ \138 \129". (Just pretend the numbers following the "\" are
decimal.)
And finally you can call my bind-xemacs-key like so:
(bind-xemacs-key "Select" 'shift 'overwrite-mode nil)
The second argument being the modifier you want to use, and the third
and forth arguments are for the normal and Meta bindings for the key
respectivly.
The lisp function should really be enhanced to automatically generate
the list of X key names to character bindings on the fly. If it can't
find the name on the list, then add it to the list with the next
available character. But, it works now. ;-)
Here is the lisp code I use on my Apollo. The bindings make
Emacs/Epoch look a lot like Apollo's DM. (Please, no flames!)
;;
;; XKEYS.EL
;;
;; Defines the extra keys that most keyboards have to send unique key sequences
;; that Emacs/Epoch won't otherwise use. This only works with X and requires a
;; working x-rebind-key or epoch::rebind-key. This is done to allow function keys
;; to directly call functions with out having to resort to the string:
;; "\e-x<function-name>"
;; or finding an unused key (how few there are) to bind the function to.
;;
;; A prefix character of \C-^ (0x1e) is used. (I hope that nobody else uses this
;; key.) Each of the prefix keys are also given a unique prefix. All of the keys
;; used (with the exception of \C-^) are greater than 0x7f, making them unproducable
;; regular keyboards.
;;
;; Bugs
;; The caps-lock key is recognized as a modifier, and I don't like it. So when your
;; caps-lock key is down, none of the function keys work.
;;
(setq xemacs-prefix-string "\C-^") ; define the prefix character to use
(setq epoch::function-key-mapping nil) ; tell Epoch to not do any function key mapping
;;
;; Defines all of the keys used on this keyboard. Each of the names that X knows the
;; key by should be listed, and a unique number should follow. Making the numbers greater
;; than 0x7f will prevent accidently mappingn to a regular key."
;;
(defvar *xemacs-keys*
'(("Select" . 129)
("Insert" . 129)
("LineDel" . 130)
("CharDel" . 131)
("Copy" . 132)
("Cut" . 132)
("Paste" . 133)
("Undo" . 133)
("Grow" . 134)
("LeftBar" . 135)
("Cmd" . 136)
("Shell" . 136)
("RightBar" . 137)
("LeftBox" . 138)
("Up" . 139)
("RightBox" . 140)
("Left" . 141)
("Next" . 142)
("Right" . 143)
("UpBox" . 144)
("Down" . 145)
("DownBox" . 146)
("F10" . 147)
("F1" . 148)
("F2" . 149)
("F3" . 150)
("F4" . 151)
("F5" . 152)
("F6" . 153)
("F7" . 154)
("F8" . 155)
("F9" . 156)
("Redo" . 157)
("Read" . 158)
("Edit" . 159)
("Save" . 159)
("Exit" . 160)
("Cancel" . 160)
("Pause" . 161)
("Help" . 161)
("KP_0" . 162)
("KP_1" . 163)
("KP_2" . 164)
("KP_3" . 165)
("KP_4" . 166)
("KP_5" . 167)
("KP_6" . 168)
("KP_7" . 169)
("KP_8" . 170)
("KP_9" . 171)
("KP_Enter" . 172)
("KP_Subtract" . 173)
("KP_Add" . 174)
("KP_Decimal" . 175)))
;;
;; The list of modifiers availible. This list shouldn't change much between hosts. The
;; first item is the X modifier. The second will be the key after the prefix. The third
;; is the prefix command for Emacs. Again, using keys greater than 0x7f."
;;
(defvar *xemacs-modifiers*
'((shift . (129 . xemacs-prefix-shift))
(lock . (130 . xemacs-prefix-lock))
(control . (131 . xemacs-prefix-control))
(meta . (132 . xemacs-prefix-meta))
(mod1 . (133 . xemacs-prefix-mod1))
(mod2 . (134 . xemacs-prefix-mod2))
(mod3 . (135 . xemacs-prefix-mod3))
(mod4 . (136 . xemacs-prefix-mod4))
(mod5 . (137 . xemacs-prefix-mod5))
(nil . (138 . xemacs-prefix-normal))))
;;
;; Define the prefix key-maps as function definitions.
;;
(define-prefix-command 'xemacs-prefix)
(define-prefix-command 'xemacs-prefix-shift)
(define-prefix-command 'xemacs-prefix-lock)
(define-prefix-command 'xemacs-prefix-control)
(define-prefix-command 'xemacs-prefix-meta)
(define-prefix-command 'xemacs-prefix-mod1)
(define-prefix-command 'xemacs-prefix-mod2)
(define-prefix-command 'xemacs-prefix-mod3)
(define-prefix-command 'xemacs-prefix-mod4)
(define-prefix-command 'xemacs-prefix-mod5)
(define-prefix-command 'xemacs-prefix-normal)
;;
;; Now define the keys in the key map for the modifiers. (This should be a loop stepping
;; through the list. But since I don't really do Lisp, I'll leave it like this.)
;;
(global-set-key xemacs-prefix-string 'xemacs-prefix)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'shift *xemacs-modifiers*)))) 'xemacs-prefix-shift)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'lock *xemacs-modifiers*)))) 'xemacs-prefix-lock)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'control *xemacs-modifiers*)))) 'xemacs-prefix-control)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'meta *xemacs-modifiers*)))) 'xemacs-prefix-meta)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'mod1 *xemacs-modifiers*)))) 'xemacs-prefix-mod1)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'mod2 *xemacs-modifiers*)))) 'xemacs-prefix-mod2)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'mod3 *xemacs-modifiers*)))) 'xemacs-prefix-mod3)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'mod4 *xemacs-modifiers*)))) 'xemacs-prefix-mod4)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc 'mod5 *xemacs-modifiers*)))) 'xemacs-prefix-mod5)
(define-key 'xemacs-prefix (char-to-string (car (cdr (assoc nil *xemacs-modifiers*)))) 'xemacs-prefix-normal)
(defun bind-xemacs-key (xemacs-key modifier binding meta-binding)
"This defines the key passed for the given modifier. It defines both the regular
key, and the meta equivelant. This is done so that ESC can still be used as a meta key.
It is accomplished by having the meta key actually send the ESC char first."
(interactive)
(let ((key-code (cdr (assoc xemacs-key *xemacs-keys*))) ; find the key code for this key
(modifier-code (car (cdr (assoc modifier *xemacs-modifiers*))))) ; and the modifier code too
(if (null key-code) ; is there such a key defined?
(error "%s is not a legal X11 key name." xemacs-key))
(if (null modifier-code) ; is there such a modifer defined?
(error "%s is not a legal X11 modifier." modifier)
(let ((key-sequence (char-to-string key-code)) ; generate a string from the key code
(modifier-sequence (char-to-string modifier-code))) ; and from the modifier code too
(let ((normal-sequence (concat xemacs-prefix-string ; put the prefix character, the modifier char
modifier-sequence key-sequence)) ; and the key character all together into a string
(meta-sequence (concat "\e" xemacs-prefix-string ; put an ESC, and the prefix char, modifier char
modifier-sequence key-sequence))) ; and the key char all together
(global-set-key normal-sequence binding) ; define a global key for the normal binding
(global-set-key meta-sequence meta-binding) ; and for the meta binding
(if (null modifier) ; is there an X modifier to tie the key to?
(progn ; nope...
(epoch::rebind-key xemacs-key 0 normal-sequence) ; bind the key with out a modifier
(epoch::rebind-key xemacs-key 'meta meta-sequence)) ; and with the meta modifier too
(progn ; yup...
(epoch::rebind-key xemacs-key modifier normal-sequence) ; bind the key with the modifier
(epoch::rebind-key xemacs-key (list modifier 'meta) meta-sequence)))))))) ; and add the meta modifier too
;;
;; Define the X keys we need. The first argument is the string that X know s the key by. The second is
;; the modifier for the key. The next two are the functions (or macros) to execute. The first is for a normal
;; (non-meta) key, and the second is for the meta.
;;
(bind-xemacs-key "Select" nil 'set-mark-command nil)
(bind-xemacs-key "Insert" 'shift 'overwrite-mode nil)
(bind-xemacs-key "LineDel" nil 'kill-whole-line nil)
(bind-xemacs-key "LineDel" 'shift 'yank-whole-line nil)
(bind-xemacs-key "CharDel" nil 'delete-char nil)
(bind-xemacs-key "Copy" nil 'copy-region-as-kill 'x-copy-region)
(bind-xemacs-key "Cut" 'shift 'kill-region 'x-cut-region)
(bind-xemacs-key "Paste" nil 'yank 'x-paste-point)
(bind-xemacs-key "Undo" 'shift 'undo nil)
(bind-xemacs-key "LeftBar" nil 'beginning-of-line nil)
(bind-xemacs-key "Cmd" nil 'execute-extended-command nil)
(bind-xemacs-key "Shell" 'shift 'new-cmushell nil)
(bind-xemacs-key "RightBar" nil 'end-of-line nil)
(bind-xemacs-key "LeftBox" nil 'dm-scroll-right nil)
(bind-xemacs-key "Up" nil 'previous-line nil)
(bind-xemacs-key "Up" 'shift "\e1\ev" nil)
(bind-xemacs-key "RightBox" nil 'dm-scroll-left nil)
(bind-xemacs-key "Left" nil 'backward-char nil)
(bind-xemacs-key "Left" 'shift 'backward-word nil)
(bind-xemacs-key "Next" nil 'other-window nil)
(bind-xemacs-key "Right" nil 'forward-char nil)
(bind-xemacs-key "Right" 'shift 'forward-word nil)
(bind-xemacs-key "UpBox" nil 'dm-scroll-down 'comint-previous-input)
(bind-xemacs-key "UpBox" 'shift 'beginning-of-buffer nil)
(bind-xemacs-key "Down" nil 'next-line nil)
(bind-xemacs-key "Down" 'shift "\e1\C-v" nil)
(bind-xemacs-key "DownBox" nil 'dm-scroll-up 'comint-next-input)
(bind-xemacs-key "DownBox" 'shift 'end-of-buffer nil)
(bind-xemacs-key "Redo" nil 'apollo-again nil)
(bind-xemacs-key "Read" nil 'find-file-read-only nil)
(bind-xemacs-key "Read" 'shift 'keyboard-find-file nil)
(bind-xemacs-key "Edit" nil 'find-file nil)
(bind-xemacs-key "Save" 'shift 'save-buffer nil)
(bind-xemacs-key "Exit" nil 'apollo-exit 'server-edit)
(bind-xemacs-key "Cancel" 'shift 'apollo-abort nil)
(bind-xemacs-key "Help" 'shift 'manual-entry nil)
(bind-xemacs-key "KP_Subtract" nil 'comint-next-input nil)
(bind-xemacs-key "KP_Add" nil 'comint-previous-input nil)
(bind-xemacs-key "F10" nil 'repeat-isearch-forward 'repeat-isearch-backward)
(bind-xemacs-key "F10" 'shift 'repeat-regexp-isearch-forward 'repeat-regexp-isearch-backward)
(bind-xemacs-key "F10" 'control 'toggle-truncate-lines nil)
(bind-xemacs-key "F1" nil 'isearch-forward 'isearch-forward-regexp)
(bind-xemacs-key "F1" 'shift 'print-buffer 'print-region)
(bind-xemacs-key "F1" 'control 'eval-current-buffer 'eval-region)
(bind-xemacs-key "F2" nil 'next-error 'compile)
(bind-xemacs-key "F2" 'shift 'save-some-buffers nil)
(bind-xemacs-key "F2" 'control 'yank-rectangle 'kill-rectangle)
(bind-xemacs-key "F3" nil 'fill-paragraph 'auto-fill-mode)
(bind-xemacs-key "F3" 'shift 'indent-region 'indent-region-for-comment)
(bind-xemacs-key "F4" nil 'indent-for-comment 'c-indent-command)
(bind-xemacs-key "F4" 'shift 'c-function-header 'c-module-header)
(bind-xemacs-key "F5" nil 'query-replace 'query-replace-regexp)
(bind-xemacs-key "F5" 'shift 'find-tag 'find-next-tag)
(bind-xemacs-key "F6" nil 'KBD-MACRO-B 'name-kbd-macro-B)
(bind-xemacs-key "F6" 'shift 'goto-mark-B 'set-mark-B)
(bind-xemacs-key "F7" nil 'KBD-MACRO-A 'name-kbd-macro-A)
(bind-xemacs-key "F7" 'shift 'goto-mark-A 'set-mark-A)
(bind-xemacs-key "F8" nil 'goto-line 'display-current-line)
(bind-xemacs-key "F8" 'shift 'vm 'mail)
(bind-xemacs-key "F8" 'control 'gnus 'gnus-post-news)
(bind-xemacs-key "F9" nil 'delete-other-windows 'remove-screen)
(bind-xemacs-key "F9" 'shift 'split-window-vertically 'duplicate-screen)
(bind-xemacs-key "F9" 'control 'enlarge-window 'shrink-window)
(global-set-mouse 2 0 'mouse-find-file)
(global-set-mouse 1 0 'gwm-choose-buffer)
--
Alan M. Carroll <-- Another casualty of applied metaphysics
Epoch Development Team
Urbana Il. "I hate shopping with the reality-impaired" - Susan
Technical Details
Message-ID:
<1992Jan21.154656.13044@m.cs.uiuc.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!uiucdcs!carrollReferences:
<1992Jan17.204624.25252@exu.ericsson.se> <1992Jan19.152150.30193@m.cs.uiuc.edu> <26571@crdgw1.crd.ge.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fc7ee,fd4adb8946f484ce X-Google-Attributes: gidfc7ee,public X-Google-ArrivalTime: 1992-01-21 09:13:54 PST Newsgroups: gnu.epoch.misc Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!uiucdcs!carroll From: carroll@cs.uiuc.edu (Alan M. Carroll) Subject: Re: Epoch and Sun 4 keyboards Message-ID: <1992Jan21.154656.13044@m.cs.uiuc.edu> Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager)) Organization: Technophiles Inc. - Engineers with Attitude References: <1992Jan17.204624.25252@exu.ericsson.se> <1992Jan19.152150.30193@m.cs.uiuc.edu> <26571@crdgw1.crd.ge.com> Date: Tue, 21 Jan 1992 15:46:56 GMT