File: tpu-edt.el.html
%% TPU-edt -- Emacs emulating TPU emulating EDT
%% Contents
% Introduction
% Differences Between TPU-edt and DEC TPU/edt
% Starting TPU-edt
% Customizing TPU-edt using the Emacs Initialization File
% Regular Expressions in TPU-edt
%% Introduction
TPU-edt emulates the popular DEC VMS editor EDT (actually, it emulates
DEC TPU's EDT emulation, hence the name TPU-edt). TPU-edt features the
following TPU/edt functionality:
. EDT keypad
. On-line help
. Repeat counts
. Scroll margins
. Learn sequences
. Free cursor mode
. Rectangular cut and paste
. Multiple windows and buffers
. TPU line-mode REPLACE command
. Wild card search and substitution
. Configurable through an initialization file
. History recall of search strings, file names, and commands
Please note that TPU-edt does NOT emulate TPU. It emulates TPU's EDT
emulation. Very few TPU line-mode commands are supported.
TPU-edt, like its VMS cousin, works on VT-series terminals with DEC
style keyboards. VT terminal emulators, including xterm with the
appropriate key translations, work just fine too.
TPU-edt works with X-windows. This is accomplished through a TPU-edt
X key map. The tpu-mapper command creates this map and stores it in a
file. See the tpu-mapper command help for more information, or just
run it and follow the directions.
%% Differences Between TPU-edt and DEC TPU/edt
In some cases, Emacs doesn't support text highlighting, so selected
regions are not shown in inverse video. Emacs uses the concept of "the
mark". The mark is set at one end of a selected region; the cursor is
at the other. In cases where the selected region cannot be shown in
inverse video an at sign (@) appears in the mode line when mark is set.
The native Emacs command ^X^X (Control-X twice) exchanges the cursor
with the mark; this provides a handy way to find the location of the
mark.
In TPU the cursor can be either bound or free. Bound means the cursor
cannot wander outside the text of the file being edited. Free means
the arrow keys can move the cursor past the ends of lines. Free is the
default mode in TPU; bound is the only mode in EDT. Bound is the only
mode in the base version of TPU-edt; optional extensions add an
approximation of free mode, see the commentary in tpu-extras.el for
details.
Like TPU, Emacs uses multiple buffers. Some buffers are used to hold
files you are editing; other "internal" buffers are used for Emacs's own
purposes (like showing you help). Here are some commands for dealing
with buffers.
Gold-B moves to next buffer, including internal buffers
Gold-N moves to next buffer containing a file
Gold-M brings up a buffer menu (like TPU "show buffers")
Emacs is very fond of throwing up new windows. Dealing with all these
windows can be a little confusing at first, so here are a few commands
to that may help:
Gold-Next_Scr moves to the next window on the screen
Gold-Prev_Scr moves to the previous window on the screen
Gold-TAB also moves to the next window on the screen
Control-x 1 deletes all but the current window
Control-x 0 deletes the current window
Note that the buffers associated with deleted windows still exist!
Like TPU, TPU-edt has a "command" function, invoked with Gold-KP7 or
Do. Most of the commands available are Emacs commands. Some TPU
commands are available, they are: replace, exit, quit, include, and
Get (unfortunately, "get" is an internal Emacs function, so we are
stuck with "Get" - to make life easier, Get is available as Gold-g).
TPU-edt supports the recall of commands, file names, and search
strings. The history of strings recalled differs slightly from
TPU/edt, but it is still very convenient.
Help is available! The traditional help keys (Help and PF2) display
a small help file showing the default keypad layout, control key
functions, and Gold key functions. Pressing any key inside of help
splits the screen and prints a description of the function of the
pressed key. Gold-PF2 invokes the native Emacs help, with its
zillions of options.
Thanks to Emacs, TPU-edt has some extensions that may make your life
easier, or at least more interesting. For example, Gold-r toggles
TPU-edt rectangular mode. In rectangular mode, Remove and Insert work
on rectangles. Likewise, Gold-* toggles TPU-edt regular expression
mode. In regular expression mode Find, Find Next, and the line-mode
replace command work with regular expressions. [A regular expression
is a pattern that denotes a set of strings; like VMS wildcards.]
Emacs also gives TPU-edt the undo and occur functions. Undo does
what it says; it undoes the last change. Multiple undos in a row
undo multiple changes. For your convenience, undo is available on
Gold-u. Occur shows all the lines containing a specific string in
another window. Moving to that window, and typing ^C^C (Control-C
twice) on a particular line moves you back to the original window
at that line. Occur is on Gold-o.
Finally, as you edit, remember that all the power of Emacs is at
your disposal. It really is a fantastic tool. You may even want to
take some time and read the Emacs tutorial; perhaps not to learn the
native Emacs key bindings, but to get a feel for all the things
Emacs can do for you. The Emacs tutorial is available from the
Emacs help function: "Gold-PF2 t"
%% Starting TPU-edt
All you have to do to start TPU-edt, is turn it on. This can be
done from the command line when running Emacs.
prompt> emacs -f tpu-edt
If you've already started Emacs, turn on TPU-edt using the tpu-edt
command. First press M-x (that's usually ESC followed by x)
and type tpu-edt followed by a carriage return.
If you like TPU-edt and want to use it all the time, you can start
TPU-edt using the Emacs initialization file, .emacs. Simply add
the following line to your init file:
(tpu-edt)
That's all you need to do to start TPU-edt.
%% Customizing TPU-edt using the Emacs Initialization File
The following is a sample Emacs initialization file. It shows how to
invoke TPU-edt, and how to customize it.
; .emacs - a sample Emacs initialization file
; Turn on TPU-edt
(tpu-edt)
; Set scroll margins 10% (top) and 15% (bottom).
(tpu-set-scroll-margins "10%" "15%")
; Load the vtxxx terminal control functions.
(load "vt-control" t)
; TPU-edt treats words like EDT; here's how to add word separators.
; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1 ; Emacs is happy to save files without a final newline; other Unix
; programs hate that! Here we make sure that files end with newlines.
(setq require-final-newline t)
; Emacs uses Control-s and Control-q. Problems can occur when using
; Emacs on terminals that use these codes for flow control (Xon/Xoff
; flow control). These lines disable Emacs's use of these characters.
(global-unset-key "\C-s")
(global-unset-key "\C-q")
; The Emacs universal-argument function is very useful.
; This line maps universal-argument to Gold-PF1.
(define-key tpu-gold-map [kp_f1
; Note that backslash (\) and double quote (") are quoted with '\\'.
(tpu-add-word-separators "]\M-x -_,.\"=+()'/*#:!&;$")
(-_,.\"=+()'/*#:!&;$")
)
; Emacs is happy to save files without a final newline; other Unix
(-_,.\"=+()'/*#:!&;$")
)
; programs hate that! Here we make sure that files end with newlines.
(-_,.\"=+()'/*#:!&;$")
)
(setq require-final-newline t)
(-_,.\"=+()'/*#:!&;$")
)
; Emacs uses Control-s and Control-q. Problems can occur when using
(-_,.\"=+()'/*#:!&;$")
)
; Emacs on terminals that use these codes for flow control (Xon/Xoff
(-_,.\"=+()'/*#:!&;$")
)
; flow control). These lines disable Emacs's use of these characters.
(-_,.\"=+()'/*#:!&;$")
)
(global-unset-key "\C-s")
(global-unset-key "\C-q")
(-_,.\"=+()'/*#:!&;$")
)
; The Emacs universal-argument function is very useful.
(-_,.\"=+()'/*#:!&;$")
)
; This line maps universal-argument to Gold-PF1.
(-_,.\"=+()'/*#:!&;$")
)
(define-key tpu-gold-map [kp_f1 'universal-argument) ; Gold-PF1
; Make KP7 move by paragraphs, instead of pages.
(define-key tpu-global-map [kf_7] 'tpu-paragraph) ; KP7
; Repeat the preceding mappings for X-windows.
(cond
(window-system
(define-key tpu-global-map [kp_7] 'tpu-paragraph) ; KP7
(define-key tpu-gold-map [kp_f1] 'universal-argument))) ; GOLD-PF1
; Display the TPU-edt version.
(tpu-version)
%% Regular Expressions in TPU-edt
Gold-* toggles TPU-edt regular expression mode. In regular expression
mode, find, find next, replace, and substitute accept Emacs regular
expressions. A complete list of Emacs regular expressions can be found
using the Emacs "info" command (it's somewhat like the VMS help
command). Try the following sequence of commands:
DO info <enter info mode>
m emacs <select the "emacs" topic>
m regexs <select the "regular expression" topic>
Type "q" to quit out of info mode.
There is a problem in regular expression mode when searching for empty
strings, like beginning-of-line (^) and end-of-line ($). When searching
for these strings, find-next may find the current string, instead of the
next one. This can cause global replace and substitute commands to loop
forever in the same location. For this reason, commands like
replace "^" "> " <add "> " to beginning of line>
replace "$" "00711" <add "00711" to end of line>
may not work properly.
Commands like those above are very useful for adding text to the
beginning or end of lines. They might work on a line-by-line basis, but
go into an infinite loop if the "all" response is specified. If the
goal is to add a string to the beginning or end of a particular set of
lines TPU-edt provides functions to do this.
Gold-^ Add a string at BOL in region or buffer
Gold-$ Add a string at EOL in region or buffer
There is also a TPU-edt interface to the native Emacs string replacement
commands. Gold-/ invokes this command. It accepts regular expressions
if TPU-edt is in regular expression mode. Given a repeat count, it will
perform the replacement without prompting for confirmation.
This command replaces empty strings correctly, however, it has its
drawbacks. As a native Emacs command, it has a different interface
than the emulated TPU commands. Also, it works only in the forward
direction, regardless of the current TPU-edt direction.
Defined variables (37)
tpu-add-at-bol-hist | History variable for tpu-edt-add-at-bol function. |
tpu-add-at-eol-hist | History variable for tpu-edt-add-at-eol function. |
tpu-advance | True when TPU-edt is operating in the forward direction. |
tpu-breadcrumb-plist | The set of user-defined markers (breadcrumbs), as a plist. |
tpu-buffer-local-map | TPU-edt buffer local key map. |
tpu-control-keys | If non-nil, control keys are set to perform TPU functions. |
tpu-direction-string | Mode line string to identify current direction. |
tpu-edt-mode | Non-nil if Tpu-Edt mode is enabled. |
tpu-edt-mode-hook | Hook run after entering or leaving ‘tpu-edt-mode’. |
tpu-global-map | TPU-edt global keymap. |
tpu-gold-map | Maps the function keys on the VT100 keyboard preceded by PF1. |
tpu-kill-buffers-silently | If non-nil, TPU-edt kills modified buffers without asking. |
tpu-last-answer | Most recent response to tpu-y-or-n-p. |
tpu-last-deleted-char | Last character deleted by a TPU-edt character-delete command. |
tpu-last-deleted-lines | Last text deleted by a TPU-edt line-delete command. |
tpu-last-deleted-region | Last text deleted by a TPU-edt remove command. |
tpu-last-deleted-words | Last text deleted by a TPU-edt word-delete command. |
tpu-last-replaced-text | Last text deleted by a TPU-edt replace command. |
tpu-newline-and-indent-p | If non-nil, Return produces a newline and indents. |
tpu-newline-and-indent-string | Mode line string to identify AutoIndent mode. |
tpu-pan-columns | Number of columns the tpu-pan functions scroll left or right. |
tpu-percent-scroll | Percentage of the screen to scroll for next/previous screen commands. |
tpu-rectangle-string | Mode line string to identify rectangular mode. |
tpu-rectangular-p | If non-nil, TPU-edt removes and inserts rectangles. |
tpu-regexp-p | If non-nil, TPU-edt uses regexp search and replace routines. |
tpu-regexp-prompt-hist | History variable for search and replace functions. |
tpu-replace-overlay | Replace highlight overlay. |
tpu-reverse | True when TPU-edt is operating in the backward direction. |
tpu-saved-control-r | Saved value of Control-r. |
tpu-saved-delete-func | Saved value of the delete key. |
tpu-search-last-string | Last text searched for by the TPU-edt search commands. |
tpu-search-overlay | Search highlight overlay. |
tpu-searching-forward | If non-nil, TPU-edt is searching in the forward direction. |
tpu-skip-chars | Characters to skip when moving by word. |
tpu-version | TPU-edt version number. |
tpu-word-separator-list | List of additional word separators. |
tpu-xkeys-file | File containing TPU-edt X key map. |