sun-keys.el 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 distributed in the hope that it will be useful,
  14. ;;; but without any warranty. No author or distributor
  15. ;;; accepts responsibility to anyone for the consequences of using it
  16. ;;; or for whether it serves any particular purpose or works at all,
  17. ;;; unless he says so in writing.
  18. ;;;
  19. ;;; Everyone is granted permission to copy, modify and redistribute
  20. ;;; GNU Emacs, but only under the conditions described in the
  21. ;;; document "GNU Emacs copying permission notice". An exact copy
  22. ;;; of the document is supposed to have been given to you along with
  23. ;;; GNU Emacs so that you can know how you may redistribute it all.
  24. ;;; It should be in a file named COPYING. Among other things, the
  25. ;;; copyright notice and this notice must be preserved on all copies.
  26. ;;;
  27. ;;; Batten@uk.ac.bham.multics (Ian G. Batten)
  28. ;;;
  29. (defun sun-function-keys-dispatch (arg)
  30. "Dispatcher for function keys."
  31. (interactive "p")
  32. (let* ((key-stroke (read t))
  33. (command (assq key-stroke sun-function-keys-command-list)))
  34. (cond (command (funcall (cdr command) arg))
  35. (t (error "Unbound function key %s" key-stroke)))))
  36. (defvar sun-function-keys-command-list
  37. '((F1 . sun-function-keys-describe-bindings)
  38. (R8 . previous-line) ; arrow keys
  39. (R10 . backward-char)
  40. (R12 . forward-char)
  41. (R14 . next-line)))
  42. (defun sun-function-keys-bind-key (arg1 arg2)
  43. "Bind a specified key."
  44. (interactive "xFunction Key Cap Label:
  45. CCommand To Use:")
  46. (setq sun-function-keys-command-list
  47. (cons (cons arg1 arg2) sun-function-keys-command-list)))
  48. (defun sun-function-keys-describe-bindings (arg)
  49. "Describe the function key bindings we're running"
  50. (interactive)
  51. (with-output-to-temp-buffer "*Help*"
  52. (sun-function-keys-write-bindings
  53. (sort (copy-sequence sun-function-keys-command-list)
  54. '(lambda (x y) (string-lessp (car x) (car y)))))))
  55. (defun sun-function-keys-write-bindings (list)
  56. (cond ((null list)
  57. t)
  58. (t
  59. (princ (format "%s: %s\n"
  60. (car (car list))
  61. (cdr (car list))))
  62. (sun-function-keys-write-bindings (cdr list)))))
  63. (global-set-key "\e*" 'sun-function-keys-dispatch)
  64. (make-variable-buffer-local 'sun-function-keys-command-list)