;; Setup sun function keys for sun terminal used with X window system. ;; Copyright (C) 1986 Free Software Foundation, Inc. ;; This file is part of GNU Emacs. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY. No author or distributor ;; accepts responsibility to anyone for the consequences of using it ;; or for whether it serves any particular purpose or works at all, ;; unless he says so in writing. Refer to the GNU Emacs General Public ;; License for full details. ;; Everyone is granted permission to copy, modify and redistribute ;; GNU Emacs, but only under the conditions described in the ;; GNU Emacs General Public License. A copy of this license is ;; supposed to have been given to you along with GNU Emacs so you ;; can know your rights and responsibilities. It should be in a ;; file named COPYING. Among other things, the copyright notice ;; and this notice must be preserved on all copies. (defun unbound-key () "Used to display a messasge about a function key not being defined." (interactive) (beep) (message "Function key %s not defined." (this-command-keys))) (defun ignore-key () "interactive version of ignore" (interactive) (ignore)) (defun scroll-down-in-place (n) (interactive "p") (previous-line n) (scroll-down n)) (defun scroll-up-in-place (n) (interactive "p") (next-line n) (scroll-up n)) (defun kill-region-and-unmark (beg end) "Like kill-region, but pops the mark [which equals point, anyway.]" (interactive "r") (kill-region beg end) (setq this-command 'kill-region-and-unmark) (set-mark-command t)) (defun prev-complex-command () "Select Previous-complex-command" (interactive) (if (zerop (minibuffer-depth)) (repeat-complex-command 1) (previous-complex-command 1))) (defun rerun-prev-command () "Repeat Previous-complex-command." (interactive) (eval (nth 0 command-history))) (defvar grep-arg nil "Default arg for RE-search") (defun grep-arg () (if (memq last-command '(research-forward research-backward)) grep-arg (let* ((command (car command-history)) (command-name (symbol-name (car command))) (search-arg (car (cdr command))) (search-command (and command-name (string-match "search" command-name))) ) (if (and search-command (stringp search-arg)) (setq grep-arg search-arg) (setq search-command this-command grep-arg (read-string "REsearch: " grep-arg) this-command search-command) grep-arg)))) (defun research-forward () "Repeat RE search forward." (interactive) (re-search-forward (grep-arg))) (defun research-backward () "Repeat RE search backward." (interactive) (re-search-backward (grep-arg))) ;;; user should (setq xterm-esc-bracket nil) in ~/.emacs to preserve (defvar xterm-esc-bracket t "If non-nil (the default) x-function-keys.el overwrites esc-[") (defvar xterm-raw-map (make-sparse-keymap) "*Keymap for ESC-[ encoded keyboard") (defun xterm-define-key (keys def) "Args KEYS, DEF. Define key sequence KEYS, s-KEYS, m-KEYS, m-s-KEYS,\n\ c-KEYS, c-m-KEYS, c-s-KEYS, and c-m-s-KEYS, in xterm-raw-map, as DEF.\n\ DEF is anything that can be a key's definition:\n\ nil (means key is undefined in this keymap),\n\ a command (a Lisp function suitable for interactive calling)\n\ a string (treated as a keyboard macro),\n\ a keymap (to define a prefix key),\n\ a list (KEYMAP . CHAR), meaning use definition of CHAR in map KEYMAP,\n\ or a symbol. The symbol's function definition is used as the key's\n\ definition, and may be any of the above (including another symbol)." (define-key xterm-raw-map keys def) (if (not (equal (substring keys 1 2) "-")) (progn (define-key xterm-raw-map (concat "s-" keys) def) (define-key xterm-raw-map (concat "m-" keys) def) (define-key xterm-raw-map (concat "c-" keys) def) (define-key xterm-raw-map (concat "m-s-" keys) def) (define-key xterm-raw-map (concat "c-s-" keys) def) (define-key xterm-raw-map (concat "c-m-" keys) def) (define-key xterm-raw-map (concat "c-m-s-" keys) def)))) (xterm-define-key "F1~" 'unbound-key) ; F1 (xterm-define-key "F2~" 'toggle-overwrite-mode) ; F2 (xterm-define-key "F3~" 'scroll-down-in-place) ; F3 (xterm-define-key "F4~" 'scroll-up-in-place) ; F4 (xterm-define-key "F5~" 'csh) ; F5 (xterm-define-key "F6~" 'shrink-window) ; F6 (xterm-define-key "F7~" 'enlarge-window) ; F7 (xterm-define-key "F8~" 'unbound-key) ; F8 (xterm-define-key "F9~" 'toggle-auto-fill-mode) ; F9 (xterm-define-key "F10~" 'unbound-key) ; F10 (xterm-define-key "F11~" 'redraw-display) ; L1 (Stop) (xterm-define-key "F12~" 'redraw-display) ; L2 (Again) (xterm-define-key "F13~" 'list-buffers) ; L3 (Props) (xterm-define-key "F14~" 'undo) ; L4 (Undo) (xterm-define-key "F15~" 'ignore-key) ; L5 (Expose-down) (xterm-define-key "F16~" 'sun-select-region) ; L6 (Put) (xterm-define-key "F17~" 'ignore-key) ; L7 (Open-down) (xterm-define-key "F18~" 'sun-yank-selection) ; L8 (Get) (xterm-define-key "F19~" 'exchange-point-and-mark) ; L9 (Find) (xterm-define-key "F20~" 'kill-region-and-unmark) ; L10 (Delete) (xterm-define-key "F21~" 'find-this-file) ; R1 (xterm-define-key "F22~" 'delete-line) ; R2 (xterm-define-key "F23~" 'delete-char) ; R3 (xterm-define-key "F24~" 'unbound-key) ; R4 (xterm-define-key "F25~" 'unbound-key) ; R5 (xterm-define-key "F26~" 'unbound-key) ; R6 (xterm-define-key "F27~" 'beginning-of-buffer) ; R7 (xterm-define-key "Home~" 'beginning-of-buffer) ; R7 [X server alt] (xterm-define-key "Up~" 'previous-line) ; R8 (up-arrow) (xterm-define-key "F28~" 'previous-line) ; R8 (for shift et al) (xterm-define-key "F29~" 'scroll-down) ; R9 (xterm-define-key "Left~" 'backward-char) ; R10 (lf-arrow) (xterm-define-key "c-Left~" 'backward-word) ; control-R10 (xterm-define-key "F30~" 'backward-char) ; R10 (for shift et al) (xterm-define-key "c-F30~" 'backward-word) ; control-R10 (xterm-define-key "F31~" 'other-window) ; R11 (xterm-define-key "Right~" 'forward-char) ; R12 (rt-arrow) (xterm-define-key "c-Right~" 'forward-word) ; control-R12 (xterm-define-key "F32~" 'forward-char) ; R12 (for shift et al) (xterm-define-key "c-F32~" 'forward-word) ; control-R12 (xterm-define-key "R13~" 'end-of-buffer) ; R13 [X server bugfix] (xterm-define-key "F33~" 'end-of-buffer) ; R13 (xterm-define-key "End~" 'end-of-buffer) ; R13 [X server alt] (xterm-define-key "Down~" 'next-line) ; R14 (dn-arrow) (xterm-define-key "F34~" 'next-line) ; R14 (for shift et al) (xterm-define-key "F35~" 'scroll-up) ; R15 ;; ;; Other keys ;; (xterm-define-key "Multi_key~" 'unbound-key) ; Sun type 4 - Compose (xterm-define-key "Prior~" 'unbound-key) ; IsCursorKey (xterm-define-key "Next~" 'unbound-key) ; IsCursorKey (xterm-define-key "Begin~" 'unbound-key) ; IsCursorKey (xterm-define-key "Select~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Print~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Execute~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Insert~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Undo~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Redo~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Menu~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Find~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Cancel~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Help~" 'help-command) ; IsMiscFunctionKey - Help (xterm-define-key "Break~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "Mode_switch~" 'unbound-key) ; IsMiscFunctionKey - Alt Graph (xterm-define-key "Num_Lock~" 'unbound-key) ; IsMiscFunctionKey (xterm-define-key "KP_Space~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_Tab~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_Enter~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_F1~" 'unbound-key) ; IsKeypadKey IsPFKey (xterm-define-key "KP_F2~" 'unbound-key) ; IsKeypadKey IsPFKey (xterm-define-key "KP_F3~" 'unbound-key) ; IsKeypadKey IsPFKey (xterm-define-key "KP_F4~" 'unbound-key) ; IsKeypadKey IsPFKey (xterm-define-key "KP_Multiply~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_Add~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_Separator~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_Subtract~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_Decimal~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_Divide~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_0~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_1~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_2~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_3~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_4~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_5~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_6~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_7~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_8~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_9~" 'unbound-key) ; IsKeypadKey (xterm-define-key "KP_Equal~" 'unbound-key) ; IsKeypadKey (if xterm-esc-bracket (progn (define-key esc-map "[" xterm-raw-map) ; Install xterm-raw-map (define-key esc-map "[[" 'backward-paragraph) ; the original esc-[ )) ;;; Since .emacs gets loaded before this file, a hook is supplied ;;; for you to put your own bindings in. (defvar xterm-sun-map-hooks nil "List of forms to evaluate after setting xterm-raw-map.") (let ((hooks xterm-sun-map-hooks)) (while hooks (eval (car hooks)) (setq hooks (cdr hooks)) ))