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