return to first page linux journal archive
keywordscontents

Listing 2. ibmkey.el

; ibmkey.el
; Copyright 1996 John F. Bunch

; Clear the key-translation-map (normally defined by loaddefs.el).
(setq key-translation-map (make-sparse-keymap))
; Switch Backspace and Delete.
(define-key key-translation-map "\177" "\^H")
(define-key key-translation-map "\^H" "\177")
; Definitions of Backspace and Delete keys as strings.
(defvar Backspace "\177")
(defvar Delete "\^H")

; Help & Undo.
(global-set-key [f1] 'help-command)
(global-set-key [f1 f1] 'help-for-help)
(global-set-key [f4] 'advertised-undo)

; Backspace.
(global-set-key Backspace 'backward-delete-char-untabify)

; Editing keypad.
(global-set-key [insert] 'overwrite-mode)
(global-set-key Delete 'delete-char)
(global-set-key [home] 'beginning-of-line)
(global-set-key [end] 'end-of-line)

; Pan (use Alt-arrows).
; Scrolls the display without moving the cursor.
(defun pan-up () (interactive)
    (scroll-up 1)
)
(defun pan-down () (interactive)
    (scroll-down 1)
)
(defun pan-right () (interactive)
    (scroll-right 1)
)
(defun pan-left () (interactive)
    (scroll-left 1)
)
(global-set-key [M-up] 'pan-up)
(global-set-key [M-down] 'pan-down)
(global-set-key [M-left] 'pan-left)
(global-set-key [M-right] 'pan-right)

; Numeric keypad.
; Define kp-f1 (Num Lock) as a prefix key.
(global-set-key [kp-f1] (make-keymap))
; Universal argument.
(global-set-key [kp-f1 kp-f1] 'universal-argument)
; Search
(global-set-key [kp-divide] 'search-backward)
(global-set-key [kp-multiply] 'search-forward)
; Cut & Paste
(global-set-key [kp-decimal] 'set-mark-command)
(global-set-key [kp-subtract] 'kill-region)    ;Cut
(global-set-key [kp-f1 kp-subtract] 'yank)     ;Paste
(global-set-key [kp-add] 'kill-ring-save)      ;Copy
(global-set-key [kp-5] 'kill-line)  ;Cut to end of line.
(global-set-key [kp-f1 kp-5] 'yank) ;Paste.
; Movement
(global-set-key [kp-7] 'beginning-of-line)
(global-set-key [kp-8] 'backward-paragraph)
(global-set-key [kp-9] 'scroll-down)
(global-set-key [kp-f1 kp-9] 'beginning-of-buffer)
(global-set-key [kp-4] 'backward-word)
(global-set-key [kp-f1 kp-4] 'backward-sentence)
(global-set-key [kp-6] 'forward-word)
(global-set-key [kp-f1 kp-6] 'forward-sentence)
(global-set-key [kp-1] 'end-of-line)
(global-set-key [kp-2] 'forward-paragraph)
(global-set-key [kp-3] 'scroll-up)
(global-set-key [kp-f1 kp-3] 'end-of-buffer)
(global-set-key [kp-enter] 'other-window)
; Toggle insert mode.
(global-set-key [kp-0] 'overwrite-mode)