*** empty log message ***
[bpt/emacs.git] / lisp / sun-keys.el
1 ;;; sun-keys.el --- support for Sun function keys
2
3 ;; Author: Ian G. Batten <batten@uk.ac.bham.multics>
4 ;; Last-Modified: 30 May 1992
5 ;; Keywords: terminals
6
7 ;;; Copyright (C) 1986 Free Software Foundation, Inc.
8 ;;;
9 ;;; This file is part of GNU Emacs.
10
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation; either version 2, or (at your option)
14 ;; any later version.
15
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING. If not, write to
23 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
24
25 ;;; Commentary:
26
27 ;;; Support (cleanly) for Sun function keys. Provides help facilities,
28 ;;; better diagnostics, etc.
29 ;;;
30 ;;; To use: make sure your .ttyswrc binds 'F1' to <ESC> * F1 <CR> and so on.
31 ;;; load this lot from your start_up
32
33 ;;; Code:
34
35 (defun sun-function-keys-dispatch (arg)
36 "Dispatcher for function keys."
37 (interactive "p")
38 (let* ((key-stroke (read t))
39 (command (assq key-stroke sun-function-keys-command-list)))
40 (cond (command (funcall (cdr command) arg))
41 (t (error "Unbound function key %s" key-stroke)))))
42
43 (defvar sun-function-keys-command-list
44 '((F1 . sun-function-keys-describe-bindings)
45 (R8 . previous-line) ; arrow keys
46 (R10 . backward-char)
47 (R12 . forward-char)
48 (R14 . next-line)))
49
50 (defun sun-function-keys-bind-key (arg1 arg2)
51 "Bind a specified key."
52 (interactive "xFunction Key Cap Label:
53 CCommand To Use:")
54 (setq sun-function-keys-command-list
55 (cons (cons arg1 arg2) sun-function-keys-command-list)))
56
57 (defun sun-function-keys-describe-bindings (arg)
58 "Describe the function key bindings we're running"
59 (interactive)
60 (with-output-to-temp-buffer "*Help*"
61 (sun-function-keys-write-bindings
62 (sort (copy-sequence sun-function-keys-command-list)
63 '(lambda (x y) (string-lessp (car x) (car y)))))))
64
65 (defun sun-function-keys-write-bindings (list)
66 (cond ((null list)
67 t)
68 (t
69 (princ (format "%s: %s\n"
70 (car (car list))
71 (cdr (car list))))
72 (sun-function-keys-write-bindings (cdr list)))))
73
74 (global-set-key "\e*" 'sun-function-keys-dispatch)
75
76 (make-variable-buffer-local 'sun-function-keys-command-list)
77
78 ;;; sun-keys.el ends here