2 ;;; Support (cleanly) for Sun function keys. Provides help facilities,
3 ;;; better diagnostics, etc.
5 ;;; To use: make sure your .ttyswrc binds 'F1' to <ESC> * F1 <CR> and so on.
6 ;;; load this lot from your start_up
9 ;;; Copyright (C) 1986 Free Software Foundation, Inc.
11 ;;; This file is part of GNU Emacs.
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)
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.
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.
27 ;;; Batten@uk.ac.bham.multics (Ian G. Batten)
30 (defun sun-function-keys-dispatch (arg)
31 "Dispatcher for function keys."
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)))))
38 (defvar sun-function-keys-command-list
39 '((F1 . sun-function-keys-describe-bindings)
40 (R8 . previous-line) ; arrow keys
45 (defun sun-function-keys-bind-key (arg1 arg2)
46 "Bind a specified key."
47 (interactive "xFunction Key Cap Label:
49 (setq sun-function-keys-command-list
50 (cons (cons arg1 arg2) sun-function-keys-command-list)))
52 (defun sun-function-keys-describe-bindings (arg)
53 "Describe the function key bindings we're running"
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)))))))
60 (defun sun-function-keys-write-bindings (list)
64 (princ (format "%s: %s\n"
67 (sun-function-keys-write-bindings (cdr list)))))
69 (global-set-key "\e*" 'sun-function-keys-dispatch)
71 (make-variable-buffer-local 'sun-function-keys-command-list)