Article View: gnu.emacs.help
Article #189396Multiple Key Binding Need Help
From: Dion Hollenbeck
Date: Mon, 04 Mar 1991 20:24
Date: Mon, 04 Mar 1991 20:24
197 lines
9382 bytes
9382 bytes
Greg George writes:
> Dudes;
> I need to find a way to bind several keys (4 or 5)
> to a emacs command. On the sun keyboard, many of the function
> keys return multiple characters. I can get two keystrokes
> to bind, but can't figure out how to get many.
I have been bouncing this around the net trying to get it to you,
so here it is in newspost instead of mail. BTW Greg, why did
this bounce?
dion
=====================================================
To: greg@enterprise
In-Reply-To: greg@enterprise.Sun.COM's message of 19 Feb 91 18:58:33 GMT
Greg -
I don't think you have asked quite the right question
due to your lack of understanding of multiple levels of key maps.
Rather than go into a long-winded discussion of the why, I will
just include the code I use to accomplish what it is obvious you
want to do. It comes from several files.
;; ======================== .emacs ==============
;; Set up second level keypad mappings
(load "goldkeys" nil t nil )
;; Set up to define Sun keymap
(defun myterm-setup-hook ()
;; ABSOLUTELY DO NOT LOAD THE BYTE-COMPILED VERSION !!!!!
(load "sunkeys.el" nil t nil)
)
(setq sun-esc-bracket t)
(setq term-setup-hook 'myterm-setup-hook)
;; =================== sunkeys.el =============
;;
;; SUN console keyboard stuff
;;
;; NOTE: This MUST NOT be run from your .emacs. Stuff necessary
;; for this to work is not yet present when your .emacs
;; is run. Run it from the command line or from a file
;; which gets run from the command line:
;;
;; alias emacs 'nemacs -l ~/Emacs/sunkeys.elc'
;;
;; hook for sun keys
(defun sun-term-hook-fun ()
(defvar sun-raw-map (make-sparse-keymap)
"*Keymap for ESC-[ encoded keyboard")
;; R keys
(define-key sun-raw-map "208z" 'GOLD-prefix) ; R1 ("gold")
(define-key sun-raw-map "209z" 'query-replace) ; R2
(define-key sun-raw-map "210z" 'yank) ; R3
(define-key sun-raw-map "211z" 'set-mark-command) ; R4
(define-key sun-raw-map "212z" 'kill-region) ; R5
(define-key sun-raw-map "213z" 'copy-region-as-kill) ; R6
;; ; R7 home
;; ; R8 uparrow
;; ; R9 pgup
;; ; R10 leftarrow
;;(define-key sun-raw-map "218z" 'something-here?) ; R11
;; ; R12 rtarrow
;; ; R13 end
;; ; R14 dnarrow
;; ; R15 pgdown
;; L keys
;;NOTE: L1 does not work
;;(define-key sun-raw-map "192z" 'nothing) ; L1
;;(define-key sun-raw-map "193z" 'nothing) ; L2
(define-key sun-raw-map "194z" 'next-start-of-line) ; L3
(define-key sun-raw-map "195z" 'next-end-of-line) ; L4
(define-key sun-raw-map "196z" 'delete-char) ; L5
(define-key sun-raw-map "197z" 'delete-current-word) ; L6
(define-key sun-raw-map "198z" 'kill-line) ; L7
(define-key sun-raw-map "199z" 'delete-current-line) ; L8
;;(define-key sun-raw-map "200z" 'nothing) ; L9
;;(define-key sun-raw-map "201z" 'nothing) ; L10
)
(setq sun-raw-map-hooks (list(sun-term-hook-fun)))
;; ====================== goldkeys.el =====================
;; set up GOLD keymap for both sun and wyse
(setq GOLD-map (make-keymap))
(fset 'GOLD-prefix GOLD-map)
(defvar GOLD-map nil
"GOLD-map maps the function keys on the keyboard preceeded
by the GOLD key. GOLD is PF1 on Wyse-75 and R1 on Sun console")
(defun define-keypad-key (keymap function-keymap-slot definition)
(let ((function-key-sequence (function-key-sequence function-keymap-slot)))
(if function-key-sequence
(define-key keymap function-key-sequence definition))))
;;Bind GOLD/Keyboard keys
(define-key GOLD-map "\C-g" 'keyboard-quit) ; just for safety
(define-key GOLD-map "\C-m" 'newline-and-indent) ;"Return"
(define-key GOLD-map " " 'undo) ;"Spacebar"
(define-key GOLD-map "=" 'goto-line) ; "="
(define-key GOLD-map "%" 'match-it) ; "%"
(define-key GOLD-map "]" 'call-last-kbd-macro) ; "]"
(define-key GOLD-map "`" 'what-line) ; "`"
(define-key GOLD-map "/" 'c-comment) ; "/"
;; (define-key GOLD-map "/" 'comment-for-c) ; "/"
(define-key GOLD-map "?" 'apropos) ; "?"
(define-key GOLD-map ">" 'attrib-region) ; ">"
(define-key GOLD-map "1" 'delete-other-windows) ; "1"
(define-key GOLD-map "2" 'split-window-vertically) ; "2"
(define-key GOLD-map "4" 'undelete-words) ; "4"
(define-key GOLD-map "5" 'undelete-lines) ; "5"
(define-key GOLD-map "6" 'insert-cfile) ; "6"
(define-key GOLD-map "7" 'insert-cfunc) ; "7"
(define-key GOLD-map "8" 'insert-cstruct) ; "8"
(define-key GOLD-map "9" 'insert-cunion) ; "9"
(define-key GOLD-map "0" 'insert-hfile) ; "0"
;; letter combinations:
(define-key GOLD-map "b" 'buffer-writeable) ; "b"
(define-key GOLD-map "B" 'buffer-writeable) ; "B"
(define-key GOLD-map "c" 'case-flip-character) ; "c"
(define-key GOLD-map "C" 'case-flip-character) ; "C"
(define-key GOLD-map "d" 'compare-windows) ; "d"
(define-key GOLD-map "D" 'compare-windows) ; "D"
(define-key GOLD-map "f" 'fill-paragraph) ; "f"
(define-key GOLD-map "F" 'auto-fill-mode) ; "F"
(define-key GOLD-map "i" 'roff-italic) ; "i"
(define-key GOLD-map "I" 'roff-italic) ; "I"
(define-key GOLD-map "l" 'downcase-word) ; "l"
(define-key GOLD-map "L" 'downcase-word) ; "L"
(define-key GOLD-map "n" 'open-line) ; "n"
(define-key GOLD-map "N" 'open-line) ; "N"
(define-key GOLD-map "o" 'overwrite-mode) ; "o"
(define-key GOLD-map "O" 'overwrite-mode) ; "O"
(define-key GOLD-map "p" 'fill-paragraph) ; "p"
(define-key GOLD-map "P" 'fill-paragraph) ; "P"
(define-key GOLD-map "r" 'rmail) ; "r"
(define-key GOLD-map "R" 'rmail-input) ; "R"
(define-key GOLD-map "s" 'shell-command) ; "s"
(define-key GOLD-map "S" 'shell-command) ; "S"
(define-key GOLD-map "t" 'c-template) ; "t"
(define-key GOLD-map "T" 'c-template) ; "T"
(define-key GOLD-map "u" 'upcase-word) ; "u"
(define-key GOLD-map "U" 'upcase-word) ; "U"
(define-key GOLD-map "v" 'send-invisible) ; "v"
(define-key GOLD-map "V" 'send-invisible) ; "V"
(define-key GOLD-map "w" 'other-window) ; "w"
(define-key GOLD-map "W" 'other-window) ; "W"
(define-key GOLD-map "x" 'finish-this-comment) ; "w"
(define-key GOLD-map "X" 'finish-this-comment) ; "W"
;; Setup second level GOLD
;;(define-keypad-key GOLD-map ?\C-b 'query-replace) ; "PF2"
;;(define-keypad-key GOLD-map ?\C-d 'send-invisible) ; "PF4"
(define-keypad-key GOLD-map ?\C-c 'eval-current-buffer) ; "PF3"
(define-keypad-key GOLD-map ?\C-b 'match-it) ; "PF2"
;; ================= end of files =================
Understand that many of the functions bound to the GOLD keys
are my local function and may not work for you, but at least
you get a complete way of setting up your own key mappings.
If you have never used a VT-100 and EDT on VAX/VMS, you may not
be familiar with the GOLD key concept. Once you press the
GOLD key, it now say "Put me in GOLD mode and the next key I press
will have a different meaning from any other time I press it".
This means that you can have as many functions bound to keys
that are NOT NOW USED BY EMACS as you have keys on the standard
keyboard TIMES 2 (shifted/unshifted).
If you need help with this, don't hesitate to ask.
--
-----
Dion Hollenbeck (619) 455-5590 x2814
Megatek Corporation, 9645 Scranton Road, San Diego, CA 92121
uunet!megatek!hollen or hollen@megatek.uucp
Technical Details
Message-ID:
<HOLLEN.91Mar4122451@valhalla.megatek.UUCP>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!jarthur!ucivax!megatek!valhalla!hollenReferences:
<9102281451.AA04180@coyote.draper.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103b8b,9f960e19889ce62 X-Google-Attributes: gid103b8b,public X-Google-ArrivalTime: 1991-03-04 18:23:25 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!jarthur!ucivax!megatek!valhalla!hollen From: hollen@megatek.UUCP (Dion Hollenbeck) Newsgroups: gnu.emacs.help Subject: Multiple Key Binding Need Help Message-ID: <HOLLEN.91Mar4122451@valhalla.megatek.UUCP> Date: 4 Mar 91 20:24:51 GMT References: <9102281451.AA04180@coyote.draper.com> Sender: hollen@megatek.UUCP Followup-To: gnu.emacs.help Organization: Megatek Corporation, San Diego, California Lines: 197 In-reply-to: mal@coyote.draper.com's message of 28 Feb 91 14:51:01 GMT