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