-;;; tpu-mapper.el --- Create a TPU-edt keymap file for x-windows emacs.
+;;; tpu-mapper.el --- create a TPU-edt X-windows keymap file
-;; Copyright (C) 1993 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
;; Author: Rob Riepel <riepel@networking.stanford.edu>
;; Maintainer: Rob Riepel <riepel@networking.stanford.edu>
-;; Keywords: tpu-edt
+;; Keywords: emulations
;; This file is part of GNU Emacs.
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING. If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING. If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
;;; Commentary:
;;; Usage:
-;; Simply load this file into the X-windows version of emacs (version 19)
-;; using the following command.
+;; Simply load this file into the X-windows version of emacs using the
+;; following command.
-;; emacs -q -l tpu-mapper.el
+;; emacs -q -l tpu-mapper
;; The "-q" option prevents loading of your .emacs file (commands therein
;; might confuse this program).
;; An instruction screen showing the TPU-edt keypad will be displayed, and
;; you will be prompted to press the TPU-edt editing keys. Tpu-mapper uses
-;; the keys you press to create an emacs lisp file that will define a
+;; the keys you press to create an Emacs Lisp file that will define a
;; TPU-edt keypad for your X server. You can even re-arrange the standard
;; EDT keypad to suit your tastes (or to cope with those silly Sun and PC
;; keypads).
;; Finally, you will be prompted for the name of the file to store the key
;; definitions. If you chose the default, TPU-edt will find it and load it
;; automatically. If you specify a different file name, you will need to
-;; set the variable "tpu-xkeys-file" before loading TPU-edt. Here's how
+;; set the variable "tpu-xkeys-file" before starting TPU-edt. Here's how
;; you might go about doing that in your .emacs file.
;; (setq tpu-xkeys-file (expand-file-name "~/.my-emacs-x-keys"))
-;; (load "tpu-edt")
+;; (tpu-edt)
;;; Known Problems:
;; Sometimes, tpu-mapper will ignore a key you press, and just continue to
;; prompt for the same key. This can happen when your window manager sucks
-;; up the key and doesn't pass it on to emacs, or it could be an emacs bug.
+;; up the key and doesn't pass it on to Emacs, or it could be an Emacs bug.
;; Either way, there's nothing that tpu-mapper can do about it. You must
;; press RETURN, to skip the current key and continue. Later, you and/or
;; your local X guru can try to figure out why the key is being ignored.
;;; Code:
-;;;
-;;; Revision Information
-;;;
-(defconst tpu-mapper-revision "$Revision: 1.3 $"
- "Revision number of TPU-edt x-windows emacs key mapper.")
-
;;;
;;; Make sure we're running X-windows and Emacs version 19
;;;
(cond
((not (and window-system (not (string-lessp emacs-version "19"))))
- (insert "
-
- Whoa! This isn't going to work...
-
- You must run tpu-mapper.el under X-windows and Emacs version 19.
-
- Press any key to exit. ")
- (sit-for 600)
- (kill-emacs t)))
+ (error "tpu-mapper requires running in Emacs 19, with an X display")))
;;;
-;;; Decide whether we're running GNU or Lucid emacs.
+;;; Decide whether we're running Lucid Emacs or Emacs itself.
;;;
(defconst tpu-lucid-emacs19-p (string-match "Lucid" emacs-version)
- "Non-NIL if we are running Lucid Emacs version 19.")
+ "Non-nil if we are running Lucid Emacs version 19.")
;;;
;;; Key variables
;;;
+(defvar tpu-kp4 nil)
+(defvar tpu-kp5 nil)
(defvar tpu-key nil)
(defvar tpu-enter nil)
(defvar tpu-return nil)
;;;
;;; Make sure the window is big enough to display the instructions
;;;
-(if tpu-lucid-emacs19-p (set-screen-size nil 80 36)
+(if tpu-lucid-emacs19-p (set-screen-size (selected-screen) 80 36)
(set-frame-size (selected-frame) 80 36))
(switch-to-buffer "Directions")
(insert "
This program prompts you to press keys to create a custom keymap file
- for use with the x-windows version of emacs and TPU-edt.
+ for use with the x-windows version of Emacs and TPU-edt.
Start by pressing the RETURN key, and continue by pressing the keys
specified in the mini-buffer. You can re-arrange the TPU-edt keypad
")
(delete-other-windows)
+(goto-char (point-min))
;;;
;;; Save <CR> for future reference
(t
(message "Hit carriage-return <CR> to continue ")
(setq tpu-return-seq (read-event))
- (setq tpu-return (concat "[" (format "%s" tpu-return-seq) "]"))))
+ (setq tpu-return (concat "[" (format "%s" tpu-return-seq) "]"))))
;;;
(format "%s" tpu-key)))
tpu-key)
-(defun tpu-gnu-map-key (ident descrip func gold-func)
+(defun tpu-emacs-map-key (ident descrip func gold-func)
(interactive)
(message "Press %s%s: " ident descrip)
(setq tpu-key-seq (read-event))
(format "%s" tpu-key)))
tpu-key)
-(fset 'tpu-map-key (if tpu-lucid-emacs19-p 'tpu-lucid-map-key 'tpu-gnu-map-key))
+(fset 'tpu-map-key (if tpu-lucid-emacs19-p 'tpu-lucid-map-key 'tpu-emacs-map-key))
(set-buffer "Keys")
(tpu-map-key "KP-1" " - The Word/Change-Case key" "'tpu-word" "'tpu-change-case")
(tpu-map-key "KP-2" " - The EOL/Delete-EOL key" "'tpu-end-of-line" "'tpu-delete-to-eol")
(tpu-map-key "KP-3" " - The Character/Special-Insert key" "'tpu-char" "'tpu-special-insert")
-(tpu-map-key "KP-4" " - The Forward/Bottom key" "'tpu-advance-direction" "'tpu-move-to-end")
-(tpu-map-key "KP-5" " - The Reverse/Top key" "'tpu-backup-direction" "'tpu-move-to-beginning")
+(setq tpu-kp4 (tpu-map-key "KP-4" " - The Forward/Bottom key" "'tpu-advance-direction" "'tpu-move-to-end"))
+(setq tpu-kp5 (tpu-map-key "KP-5" " - The Reverse/Top key" "'tpu-backup-direction" "'tpu-move-to-beginning"))
(tpu-map-key "KP-6" " - The Remove/Insert key" "'tpu-cut" "'tpu-paste")
(tpu-map-key "KP-7" " - The Page/Do key" "'tpu-page" "'execute-extended-command")
(tpu-map-key "KP-8" " - The Section/Fill key" "'tpu-scroll-window" "'tpu-fill")
(insert (format "(define-key minibuffer-local-completion-map %s 'exit-minibuffer)\n" tpu-enter))
(insert (format "(define-key minibuffer-local-must-match-map %s 'minibuffer-complete-and-exit)\n" tpu-enter))))
+(cond
+ ((not (or (equal tpu-kp4 tpu-return) (equal tpu-kp5 tpu-return)))
+ (insert "
+;; Minibuffer map additions to allow KP-4/5 termination of search strings.
+;;
+")
+
+ (insert (format "(define-key minibuffer-local-map %s 'tpu-search-forward-exit)\n" tpu-kp4))
+ (insert (format "(define-key minibuffer-local-map %s 'tpu-search-backward-exit)\n" tpu-kp5))))
+
(insert "
;; Define the tpu-help-enter/return symbols
;;
(cond (tpu-lucid-emacs19-p
(insert (format "(setq tpu-help-enter \"%s\")\n" tpu-enter-seq))
- (insert (format "(setq tpu-help-return \"%s\")\n" tpu-return-seq)))
+ (insert (format "(setq tpu-help-return \"%s\")\n" tpu-return-seq))
+ (insert "(setq tpu-help-N \"[#<keypress-event N>]\")\n")
+ (insert "(setq tpu-help-n \"[#<keypress-event n>]\")\n")
+ (insert "(setq tpu-help-P \"[#<keypress-event P>]\")\n")
+ (insert "(setq tpu-help-p \"[#<keypress-event p>]\")\n"))
(t
(insert (format "(setq tpu-help-enter \"%s\")\n" tpu-enter))))
(set-buffer "Keys")
;;;
-;;; Save the key mapping program and blow this pop stand
+;;; Save the key mapping program
;;;
-(let ((file (if tpu-lucid-emacs19-p "~/.tpu-lucid-keys" "~/.tpu-gnu-keys")))
+(let ((file
+ (convert-standard-filename
+ (if tpu-lucid-emacs19-p "~/.tpu-lucid-keys" "~/.tpu-keys"))))
(set-visited-file-name
- (read-file-name (format "Save key mapping to file (default %s): " file) nil file)))
+ (read-file-name (format "Save key mapping to file (default %s): " file) "" file)))
(save-buffer)
-(message "That's it! Press any key to exit")
-(sit-for 600)
-(kill-emacs t)
+;;;
+;;; Load the newly defined keys and clean up
+;;;
+(eval-current-buffer)
+(kill-buffer (current-buffer))
+(kill-buffer "*scratch*")
+(kill-buffer "Gold-Keys")
+
+;;;
+;;; Let them know it worked.
+;;;
+(switch-to-buffer "Directions")
+(erase-buffer)
+(insert "
+ A custom TPU-edt keymap file has been created.
+
+ Press GOLD-k to remove this buffer and continue editing.
+")
+(goto-char (point-min))
+;;; arch-tag: bab5872f-cd3a-4c1c-aedb-047b67646f6c
;;; tpu-mapper.el ends here