home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / packages / input-remapping / text0007.txt < prev    next >
Encoding:
Text File  |  1990-07-22  |  9.9 KB  |  286 lines

  1.  
  2.     HP/ISI input remapping files:  Part 7 of 8
  3.  
  4.     This is a complete copy of lisp/term/default_keymap.el, the
  5.     default HP-specific keyboard setup.  It contains four parts:
  6.  
  7.     1.  A copy of bobcat.el's logic to swap contro-H and ascii del.
  8.         It's an artifact of history -- at one time I was expecting
  9.         to replace bobcat.el with this.
  10.  
  11.     2.  A run of x-rebind-keysym invocations to bind a string of the
  12.         form "^X^Ykeyname" to each "non-ascii" keysym.  "keyname"
  13.         is normally the string that X11 associates with each keysym.
  14.         The exceptions marked by '****' comments prevent emacs from
  15.         interpreting one keysym as a prefix for another.
  16.  
  17.     3.  A few functions are defined for use in the last part.
  18.  
  19.     4.  A run of global-set-key functions defines what each key does.
  20.  
  21.  
  22.     It's also possible to just use x-rebind-keysym to map to
  23.     "standard" emacs commands.  However, there are a few pitfalls
  24.     involving shift keys (as noted in connection with x11term.c),
  25.     and using this technique on the first go-around produced a
  26.     VERY cryptic elisp file that proved hard to maintain before
  27.     its prototype was finished!
  28.  
  29.  
  30. ------------------------------  Cut  Here  --------------------------------
  31. ;;
  32. ;;    HP function key rebindings for X11
  33. ;;    4-25-89        Paul Raveling
  34. ;;
  35.  
  36. ;;    The next section, which swaps control-H and ascii del, is
  37. ;;    a verbatim copy of the original term/bobcat.el.  All other
  38. ;;    definitions and logic is
  39.  
  40. ;;; HP terminals usually encourage using ^H as the rubout character
  41.  
  42. (let ((the-table (make-string 128 0)))
  43.   (let ((i 0))
  44.     (while (< i 128)
  45.       (aset the-table i i)
  46.       (setq i (1+ i))))
  47.   ;; Swap ^H and DEL
  48.   (aset the-table ?\177 ?\^h)
  49.   (aset the-table ?\^h ?\177)
  50.   (setq keyboard-translate-table the-table))
  51.  
  52.  
  53.  
  54. ;;;;    Bind keysyms to escape sequences consistent with
  55. ;;;;    the distributed version of emacs
  56.  
  57. (x-rebind-keysym "Left"        nil    "Left")
  58. (x-rebind-keysym "Right"    nil    "Right")    ;  Arrow
  59. (x-rebind-keysym "Up"        nil    "Up")    ;  Keys
  60. (x-rebind-keysym "Down"        nil    "Down")
  61.  
  62. (x-rebind-keysym "F1"        nil    "F1")
  63. (x-rebind-keysym "F2"        nil    "F2")
  64. (x-rebind-keysym "F3"        nil    "F3")
  65. (x-rebind-keysym "F4"        nil    "F4")
  66. (x-rebind-keysym "F5"        nil    "F5")
  67. (x-rebind-keysym "F6"        nil    "F6")
  68. (x-rebind-keysym "F7"        nil    "F7")
  69. (x-rebind-keysym "F8"        nil    "F8")
  70. (x-rebind-keysym "F9"        nil    "F9")
  71. (x-rebind-keysym "F10"        nil    "F10")
  72. (x-rebind-keysym "F11"        nil    "F11")
  73. (x-rebind-keysym "F12"        nil    "F12")
  74. (x-rebind-keysym "F13"        nil    "F13")
  75. (x-rebind-keysym "F14"        nil    "F14")
  76. (x-rebind-keysym "F15"        nil    "F15")
  77. (x-rebind-keysym "Help"        nil    "Help")
  78. (x-rebind-keysym "F16"        nil    "F16")
  79. (x-rebind-keysym "Menu"        nil    "Menu")
  80. (x-rebind-keysym "F17"        nil    "F17")
  81. (x-rebind-keysym "F18"        nil    "F18")
  82. (x-rebind-keysym "F19"        nil    "F19")
  83. (x-rebind-keysym "F20"        nil    "F20")
  84.  
  85. (x-rebind-keysym "Find"        nil    "Find")
  86. (x-rebind-keysym "Insert"    nil    "Insert")
  87. ;;(x-rebind-keysym "Delete"    nil    "Delete_DEL")
  88. (x-rebind-keysym "Select"    nil    "Select")
  89. (x-rebind-keysym "Prior"    nil    "Prior")
  90. (x-rebind-keysym "Next"        nil    "Next")
  91.  
  92.  
  93. ;;;;    Bind keysyms unused by distributed version of emacs
  94. ;;;;    but used on HP keyboards to escape sequences
  95.  
  96. (x-rebind-keysym "Tab"        nil    "Tab")
  97. (x-rebind-keysym "Tab_backward"    nil    "backward_Tab")    ; ****
  98. (x-rebind-keysym "Execute"    nil    "Enter")    ; Actually, enter
  99. (x-rebind-keysym "Print"    nil    "Print")
  100. (x-rebind-keysym "Break"    nil    "Break")
  101. (x-rebind-keysym "Reset"    nil    "Reset")
  102. (x-rebind-keysym "Cancel"    nil    "Cancel")
  103. (x-rebind-keysym "System"    nil    "System")
  104. (x-rebind-keysym "User"        nil    "User")
  105. (x-rebind-keysym "Clear_line"    nil    "Clear_line")
  106. (x-rebind-keysym "Clear"    nil    "Clear_display")    ; ****
  107. (x-rebind-keysym "Insert_line"    nil    "Insert_line")
  108. (x-rebind-keysym "Delete_line"    nil    "Delete_line")
  109. (x-rebind-keysym "Insert_char"    nil    "Insert_char")
  110. (x-rebind-keysym "Delete_char"    nil    "Delete_char")
  111. (x-rebind-keysym "Home"        "none"    "Home")
  112. (x-rebind-keysym "Home"        "shift"    "Shift_Home")
  113. (x-rebind-keysym "KP_F1"    nil    "KP_F1")
  114. (x-rebind-keysym "KP_F2"    nil    "KP_F2")
  115. (x-rebind-keysym "KP_F3"    nil    "KP_F3")
  116. (x-rebind-keysym "KP_F4"    nil    "KP_F4")
  117. (x-rebind-keysym "KP_Multiply"    nil    "KP_Multiply")
  118. (x-rebind-keysym "KP_Divide"    nil    "KP_Divide")
  119. (x-rebind-keysym "KP_Add"    nil    "KP_Add")
  120. (x-rebind-keysym "KP_Subtract"    nil    "KP_Subtract")
  121. (x-rebind-keysym "KP_7"        nil    "KP_7")
  122. (x-rebind-keysym "KP_8"        nil    "KP_8")
  123. (x-rebind-keysym "KP_9"        nil    "KP_9")
  124. (x-rebind-keysym "KP_Enter"    nil    "KP_Enter")
  125. (x-rebind-keysym "KP_4"        nil    "KP_4")
  126. (x-rebind-keysym "KP_5"        nil    "KP_5")
  127. (x-rebind-keysym "KP_6"        nil    "KP_6")
  128. (x-rebind-keysym "KP_Separator"    nil    "KP_Separator")
  129. (x-rebind-keysym "KP_1"        nil    "KP_1")
  130. (x-rebind-keysym "KP_2"        nil    "KP_2")
  131. (x-rebind-keysym "KP_3"        nil    "KP_3")
  132. (x-rebind-keysym "KP_Tab"    "none"    "KP_Tab")
  133. (x-rebind-keysym "KP_Tab_backward" "shift" "KP_backward_Tab") ; ****
  134. (x-rebind-keysym "KP_0"        nil    "KP_0")
  135. (x-rebind-keysym "KP_Decimal"    nil    "KP_Decimal")
  136.  
  137.  
  138.  
  139. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  140. ;    Simple non-standard functions to support key bindings         ;
  141. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  142.  
  143. (defun delete-this-line ()
  144.   "Delete current line, save as kill"
  145.     (interactive)
  146.     (let (curcol dot1)
  147.     (setq curcol (current-column))
  148.     (forward-line 0)
  149.     (setq dot1 (dot))
  150.     (forward-line 1)
  151.     (kill-region dot1 (dot))
  152.     (move-to-column curcol)))
  153.  
  154. (defun clear-this-line ()
  155.   "Delete contents of current line, save as kill"
  156.     (interactive)
  157.     (forward-line 0)
  158.     (kill-line))
  159.  
  160. (defun clear-entire-buffer ()
  161.   "Delete contents of entire buffer, save as kill"
  162.     (interactive)
  163.     (mark-whole-buffer)
  164.     (kill-region 1 (region-end)))
  165.  
  166. (defun switch-to-prev-buffer ()
  167.   "Switch to previous buffer:  Like switch-to-buffer, but without interaction"
  168.     (interactive)
  169.     (switch-to-buffer (other-buffer (current-buffer))))
  170.  
  171. (defun start-end-kbd-macro ()
  172.   "Start/stop capturing keystrokes for keyboard macro"
  173.     (interactive)
  174.     (if defining-kbd-macro
  175.         (end-kbd-macro)
  176.         (start-kbd-macro nil)))
  177.  
  178. (defun keys ()
  179.   "Describe default HP key functions"
  180.   (interactive)
  181.   (view-file "/usr/local/gemacs-18.54/etc/HP_keys.text"))
  182.  
  183.  
  184. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  185. ;    Map specific escape sequences       ;
  186. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  187.  
  188. (global-unset-key "\e[")        ; Unmap escape-left-bracket
  189.  
  190.  
  191. ;    Function key row along top of main cluster
  192.  
  193. (global-set-key    "Break" 'save-buffer)    ; Break:  Save buffer
  194. (global-set-key    "Reset" 'revert-buffer)    ; Reset:  Revert buffer
  195. (global-set-key    "Cancel" 'save-buffers-kill-emacs) ; Stop:  Exit gracefully
  196.  
  197. (global-set-key    "F1" 'call-last-kbd-macro)    ; f1:    Execute macro
  198. (global-set-key    "F2" 'start-end-kbd-macro)    ; f2:   Start/end macro def
  199. (global-set-key    "F3" 'bury-buffer)        ; f3:    Switch to next buffer
  200. (global-set-key    "F4" 'switch-to-prev-buffer); f4:    Switch to prev buffer
  201. (global-set-key    "Menu" 'list-buffers)    ; Menu: Buffer menu
  202. (global-set-key    "System" 'dired)        ; System: 'Edit' directory
  203. (global-set-key    "User" 'rmail)        ; User: 'Edit' mail
  204. (global-set-key    "F5" 'delete-other-windows)    ; f5:     Edit just 1 buffer
  205. (global-set-key    "F6" 'replace-string)    ; f6:     Replace string
  206.  
  207. ;;    If not for searches recognizing ^s & ^r when parsing pattern:
  208. ;(global-set-key "F7" 'isearch-backward)    ; f7:    Search backward
  209. ;(global-set-key "F8" 'isearch-forward)    ; f8:    Search forward
  210. ;;    But instead:
  211. (x-rebind-keysym "F7"        nil    "")    ; f7:    Search backward
  212. (x-rebind-keysym "F8"        nil    "")    ; f8:    Search forward
  213.  
  214. (global-set-key    "Clear_line" 'clear-this-line) ; Clear line:  Clear line
  215. (global-set-key    "Clear_display" 'clear-entire-buffer); Clear display:  Clear buffer
  216.  
  217.  
  218.  
  219. ;    Special purpose keys in main key cluster
  220.  
  221. ;;;(global-set-key    "Tab" 'backward-kill-word)    ; Tab:  Delete word backward
  222. ;;;(global-set-key    "backward_Tab" 'kill-word)    ; Shift-Tab:  Del word forward
  223. (global-set-key    "Tab" 'tab-to-tab-stop)    ; Tab:  Tab forward
  224. (global-set-key    "backward_Tab" 'tab-to-tab-stop)    ; Shift-Tab:  Same
  225. ;;(global-set-key    "Delete_DEL" 'keyboard-quit); DEL:  Abort command
  226. (global-set-key    "Enter" 'find-file)        ; Enter:  Find file
  227. (global-set-key    "Print" 'insert-file)    ; Print:  Insert file
  228.  
  229. (global-set-key    "Insert_line" 'open-line)    ; Insert line:  Split line
  230. (global-set-key    "Delete_line" 'delete-this-line) ; Delete line:  Del line
  231. (global-set-key    "Insert_char" 'overwrite-mode); Insert char:  Toggle ovrwrt
  232. (global-set-key    "Delete_char" 'delete-char)    ; Delete char:  Delete char
  233. (global-set-key    "Home" 'beginning-of-buffer); Home:  Go to start of buffer
  234. (global-set-key    "Shift_Home" 'end-of-buffer); Shift Home:  Go to end of buf
  235. (global-set-key    "Select"  'exchange-point-and-mark)    ; Select:  Retreat!
  236. (global-set-key    "Prior"  'scroll-down)    ; Prev:  Scroll back 1 page
  237. (global-set-key    "Next"  'scroll-up)        ; Next:  Scroll fwd 1 page
  238.  
  239. (global-set-key "Left"  'backward-char)    ; Left arrow:  Move left
  240. (global-set-key "Right"  'forward-char)    ; Left arrow:  Move left
  241. (global-set-key "Up"  'previous-line)    ; Left arrow:  Move left
  242. (global-set-key "Down"  'next-line)        ; Left arrow:  Move left
  243.  
  244.  
  245.  
  246. ;    Keypad cluster
  247.  
  248.  
  249. ;    Unmarked function keys on top row:
  250.  
  251. (global-set-key    "KP_F1" 'apropos)        ; Keypad F1:  Apropos
  252. (global-set-key    "KP_F2" 'describe-key)    ; Keypad F2:  Describe key
  253. (global-set-key    "KP_F3" 'describe-bindings)    ; Keypad F3:  Describe keys
  254. (global-set-key    "KP_F4" 'describe-function)    ; Keypad F4:  Describe function
  255.  
  256.  
  257. ;    Big keys:
  258.  
  259. (global-set-key    "KP_Tab" 'goto-line)    ; Keypad Tab:    Go to line [#]
  260. (global-set-key    "KP_backward_Tab" 'what-line); Shift KP Tab:  Report line #
  261. (global-set-key    "KP_0" 'undo)        ; Keypad 0:  Undo
  262.  
  263. ;    Little keys:  Mode settings
  264.  
  265. (global-set-key    "KP_Multiply"    'text-mode)
  266. (global-set-key    "KP_Divide"        'indented-text-mode)
  267. (global-set-key    "KP_Add"        'outline-mode)
  268. (global-set-key    "KP_Subtract"    'fundamental-mode)
  269.  
  270. (global-set-key    "KP_7"        'c-mode)
  271. (global-set-key    "KP_8"        'lisp-mode)
  272. (global-set-key    "KP_9"        'emacs-lisp-mode)
  273. (global-set-key    "KP_Enter"        'lisp-interaction-mode)
  274.  
  275. (global-set-key    "KP_4"        'latex-mode)
  276. (global-set-key    "KP_5"        'plain-tex-mode)
  277. (global-set-key    "KP_6"        'scribe-mode)
  278. (global-set-key    "KP_Separator"    'nroff-mode)
  279.  
  280. (global-set-key    "KP_1"        'copy-region-as-kill)
  281. (global-set-key    "KP_2"        'kill-region)
  282. (global-set-key    "KP_3"        'yank)
  283. (global-set-key    "KP_Decimal"    'set-mark-command)
  284.  
  285.  
  286.