\documentstyle[11pt]{article}
% Anfang DINA4
\pagestyle{empty}
\topmargin-12mm
\headheight0mm
\headsep0mm
\oddsidemargin0mm
\evensidemargin0mm
\textwidth155mm
\textheight255mm
\baselineskip1.5mm
\parindent0mm
\footheight1.5em
\footskip2.5em
%Ende DINA4

\begin{document}
\vspace*{8cm}
\centerline{\huge\bf edt-vt100-kbd V1.03}
\par
\vspace{2cm}
\centerline{\Large\bf An edt keypad patch script for Linux}
\par
\vspace{3em}
\centerline{\large\bf EDV-Beratung Kurt Schneider}
\centerline{\large\bf Hans-$\!$Vogel-Strasse 137}
\centerline{\large\bf D-90765 Fuerth}
\centerline{\large\bf Tel. +49 / 911 / 79 29 93}
\centerline{\large\bf Fax. +49 / 911 / 79 40 722}
\centerline{\large\bf e-mail: kschneid@biologie.uni-erlangen.de}
\pagebreak
\pagestyle{plain}
\setcounter{page}{1}
\section{Who needs this code?}
This code is especially intended for people who work both with
keypad editors (EDT, KED, K52) as they are found on DEC machines
and with Linux. This code enables you to use your skill learned
on the DEC machines also on the Linux boxes. Anybody who finds
{\tt vi} and {\tt emacs} good, but keypad editors better, will
be happy with this keyboard remapping.
\par
Furthermore you can use it for patching your keyboard layout in
order to conform to VT100, so that you can run applications that
expect VT100 escape codes.
\par
\section{Introduction}
{\bf edt-vt100-kbd} is a shell script to map your keyboard to
VAX-VMS-EDT style under Linux.
GNU emacs has a VAX-VMS-EDT emulation mode, that makes it look like
the wellknown EDT keypad editor of VAX (and KED on PDP11, maybe).
One problem that you will encounter is that this works fine on DEC VT220
and VT320 terminals, but not so on the console. This is because DEC
terminals have a feature to remap the keypad keys whenever emacs starts
up. PCs are missing that so we have to map the keypad keys as needed.
\par
\section{What the package includes}
You should have got the following files:
\par
\begin{center}
\begin{tabular}{l|l}
  {\bf File} & {\bf Description}\\
  \hline
  {\tt README} & a very short description of the package\\
  {\tt edt-vt100-1.03.lsm} & a short description of the package\\
  {\tt edt-vt100-kbd.sh} & the installation script\\
  {\tt edt} & a script for calling emacs in edt mode \\
  {\tt .emacs.edt} & emacs startup script with edt functionality\\
  {\tt edt-vt100-kbd.tex} & description of the package (\TeX-source)\\
  {\tt edt-vt100-kbd.dvi} & description of the package (\TeX-dvi-file)\\
  {\tt edt-vt100-kbd.ps} & description of the package (ready to print)\\
  {\tt edt-vt100-kbd.txt} & description of the package (plain ASCII)\\
\end{tabular}
\end{center}
\par
\section{Prerequisites}
If you want the VT100 functionality, you need:
\begin{itemize}
  \item Linux (maybe this piece of code works on other platforms,
	but I haven't tested it). Should there be any need, please
	let me know
  \item this package ({\tt edt-vt100-kbd})
\end{itemize}
If you want edt functionality, you need additionaly:
\begin{itemize}
  \item GNU Emacs
  \item some lisp scripts that came with GNU Emacs (e.\ g.\ {\tt tpu-edt.el})
\end{itemize}
\par
\section{Installation}
I've tried to make the installation as easy as possible. Installation
is a four step process:
\par
\begin{enumerate}
  \item back up your machine (when have you done it for the last time??)
  \item unpacking the distribution file (supposedly you have done
	this already) ;-)
  \item making and installing the new keyboard table. This produces VT100
	keyboard mapping
  \item preparation of the edt scripts
\end{enumerate}
\par
\subsection{Unpacking the distribution file}
\par
To unpack the distribution file, you should do the following:
\par
\begin{itemize}
  \item make a temporary directory (maybe \$HOME/tmp)
  \item change to this new directory
  \item copy your original keytable to this new directory
  \item copy the {\tt edt-vt100-kbd} package to this new directory
  \item unzip and untar the package ({\tt tar xzvf edt-vt100-kbd-1.03.tar.gz})
  \item that's it
\end{itemize}
\par
\subsection{Making and installing the new keyboard table}
There is a shell wrapper called {\tt edt-vt100-kbd.sh}, which does the
following:
\par
\begin{itemize}
  \item it asks you where your original keytable resides. I strongly
	recommend to use a copy of the original one in case anything
	goes wrong, although {\tt edt-vt100-kbd.sh} doesn't modify this file
  \item it searches the offending key descriptions and modifies them
	as needed
  \item it writes a new table called edt-vt100-kbd.map
  \item if you didn't load a keytable up to now, grab one that fits your
	taste and modify this one
\end{itemize}
\par
You have to be superuser to make these changes:
\begin{itemize}
  \item call {\tt ./edt-vt100-kbd.sh} and answer the question
  \item move the new keytable to where the other ones reside (supposedly
	in the directory {\tt /var/lib/kbd/keytables}). Don't overwrite
	another file
  \item this map should be loaded at startup by one of your {\tt rc*} files,
	{\tt /etc/rc}, {\tt /etc/rc.local} or {\tt /etc/rc.d/rc.keymap}.
	Have a look at these files. If you don't use US-style keyboard
	layout, you should find two lines that read like this:
	\par
	\vspace{.5em}
	{\tt echo 'Loading keyboard map "de-lat1-nd.map"...'}
	\par
	{\tt loadkeys /var/lib/kbd/keytables/de-lat1-nd.map}
	\par
	\vspace{.5em}
	(or similar). If you find them, make a copy of them,
	comment the original (by prepending a {\tt \#} in front of each line)
	and change the copy to:
	\par
	\vspace{.5em}
	{\tt echo 'Loading keyboard map "edt-vt100-kbd.map"...'}
	\par
	{\tt loadkeys /var/lib/kbd/keytables/edt-vt100-kbd.map}
	\par
	\vspace{.5em}
	If you use US-style keyboard layout or didn't load a keytable up
	to now, insert these two lines, preferedly at the end of the file.
  \item reboot your machine
\end{itemize}
\par
If you only need VT100 keyboard layout and no edt emulation, you're done
with the installation.
\par
\vspace{1em}
\subsection{Prepation of the edt scripts}
If you need edt emulation, there is another file for you called {\tt edt}.
It does the following:
\par
\begin{itemize}
  \item it starts up emacs in edt-emulation mode
\end{itemize}
\par
\vspace{.5em}
And there is still another file called {\tt .emacs.edt}, which should
be copied to the home directory of anyone who wants to work with edt.
\par
\vspace{1em}
You have to:
\par
\begin{itemize}
  \item copy the file {\tt edt} to where your executables reside, maybe
	{\tt /usr/local/bin}
  \item copy {\tt .emacs.edt} to the home directory of anyone who wants
	to work with edt (don't forget to make these users owner of the
	file)
  \item copy the file {\tt \$HOME/.emacs} to {\tt \$HOME/.emacs.org}.
	It will be copied to {\tt \$HOME/.emacs} if you don't need
	EDT compatibility
\end{itemize}
\par
\subsection{After the installation: Starting EDT}
If you have installed edt-vt100-kbd, you can call it with
\par
\vspace{1em}
{\tt \$ edt file}
\par
\vspace{1em}
instead of
\par
\vspace{1em}
{\tt \$ emacs file}
\par
\vspace{1em}
and have the functionality of EDT as on your VAX.
\par
\vspace{.5em}
There is an option that resembles the EDT-call
\par
\vspace{1em}
{\tt EDT/OU:FILE1 FILE2}
\par
\vspace{1em}
on the VAX. Here you have to input the following line:
\par
\vspace{1em}
{\tt edt -o file1 file2}
\par
\vspace{1em}
This reads the contents of {\tt file2} (the input file), lets you edit
the text, and when you exit {\tt edt}, the text is saved under the
name {\tt file1} (the output file). If {\tt file1} already existed before,
its contents is moved to \verb+file1~+. Should you leave {\tt edt} with
quit without writing, everything is as it was before. I.\ e.\ if {\tt file1}
didn't exist, it doesn't exist now. If {\tt file1} existed
before, it exists under its original name (it is moved back from
\verb+file1~+ to {\tt file1}).
\par
This option doesn't work if you don't have write or execute permission
in the output directory and it doesn't work if {\tt file2} doesn't exist.
\par
\section{Deinstallation}
\par
Should you ever want to get rid of this package, do the following:
\par
\vspace{.5em}
If (and only if) no one wants to use it anymore, then:
\begin{itemize}
  \item restore the entries in your startup file {\tt /etc/rc},
	{\tt /etc/rc.local} or in the file called {\tt /etc/rc.d/rc.keymap}.
	You've kept a copy of the original line, haven't you?
  \item should you have loaded no keytable before, remove the
	lines that load the new keytable {\tt edt-vt100-kbd.map}
\end{itemize}
\par
\section{Bugs, Problems and Limitations}
I've tested {\tt edt-vt100-kbd} on Slackware Linux and it worked fine.
\par
\begin{enumerate}
  \item Since the PC-keyboards have only three keys on the right side
	of the keypad, I wasn't able to implement DelC and UnDelC
	(delete and undelete character). You could remap it to the
	Del key, but then there is no more Ctrl-Alt-Del. Any
	suggestions anyone?
  \item You can't use $<$NL$>$ within search strings, since the
	search starts as soon as you press Return, but this seems
	to be a limitation of emacs. Instead you should use
	text\^{ }V\^{ }Jtext to search for an embedded $<$NL$>$
	(\^{ }V escapes the $<$NL$>$).
  \item There is some interference with emacs commands. I didn't
	bother much, because if anything goes wrong, you can use
	{\em them} to leave emacs
  \item A search doesn't start when you press {\tt advance} or {\tt backup}
	but only if you hit {\tt Enter}. This seems to be a bug in
	some older versions of the edt-emulation of emacs. Older emulations
	showed this feature, the newer releases (I tested Slackware 1.2.6)
	are o.k.
  \item There is no journal file in case the machine or emacs dies.
	It is an emacs feature to write a file called {\tt \#filename\#},
	which contains the actual state of the document (well, within
	some hundred key strokes).
  \item I had to remap some function keys (starting with F10) in order
	to provide full keypad functionality. Programs relying on function
	keys starting with F10 wouldn't work correctly with this keymap.
	You have to unload it temporarily.
  \item If you stand within a line and say REVERSE - LINE, the cursor
	is moved to the line before the current one and not to the
	beginning of the actual one. This is a bug. The fix should
	make it into emacs version 19.30. If you have an older one,
	here is a patch from Rob Riepel: there is a function
	tpu-backward-line in both tpu-edt.el and tpu-extras.el. 
	The line that must be added is:
	\par
	{\tt (or (bolp) (>= 0 num) (setq num (- num 1)))}
	\par
	The context is in tpu-edt.el:
	\par
	\begin{verbatim}
	(defun tpu-backward-line (num)
	  "Move to beginning of previous line.
	Prefix argument serves as repeat count."
	  (interactive "p")
	  (or (bolp) (>= 0 num) (setq num (- num 1)))
	  (forward-line (- num)))
	\end{verbatim}
	and in tpu-extras.el:
	\par
	\begin{verbatim}
	(defun tpu-backward-line (num)
	  "Move to beginning of previous line.
	Prefix argument serves as repeat count."
	  (interactive "p")
	  (let ((beg (tpu-current-line)))
	    (or (bolp) (>= 0 num) (setq num (- num 1)))
	    (next-line-internal (- num))
	    (tpu-top-check beg num)
	    (beginning-of-line)))
	\end{verbatim}
	If you make these changes in your copy, be sure to
	byte-compile the changed file so the *.elc files are updated.  
\end{enumerate}
\par
\section{History}
\begin{description}
  \item [V1.00:] The very beginning. Since I grew up with
	DEC machines like PDP11 and VAX, the keypad editor was the most
	missing tool when I moved from these computers to U{\sc nix}.
	Since there was an EDT emulation script for Emacs written by
	Rob Riepel (riepel@networking.stanford.edu), I tried it out
	and found that it worked well on VT220/VT320 terminals, but
	not so on the PC-console. So I decided to patch the keymapping
	in order to make the EDT emulation work.
  \item [V1.01:] What was missing from the first version was the
	command {\tt set screen 5:20}, which moves the screen up/down
	when the cursor has only a distance of 5 lines from the
	bottom/top of the screen, so that you can see what comes
	next under/above the current line. This is achieved by the line
	\par
	\verb+ (tpu-set-scroll-margins "5" "5")  ;  Set scroll margins.+
	\par
	in the file {\tt \$HOME/.emacs.edt}, which is copied into place
	as needed. Since edt-emulation is activated from within
	{\tt \$HOME/.emacs.edt}, there is no more need to supply
	a path to the emulation scripts.
  \item [V1.02:] From this version on the package is called
	{\tt edt-vt100-kbd} to stress the VTxxx escape code
	feature of the code
	\par
	\begin{itemize}
	  \item use of {\tt /bin/sh} instead of {\tt /bin/ksh} to interpret
		the scripts
	  \item the keytables are loaded permanently, decreasing the
		startup time. Leaving edt doesn't remap the keyboard,
		so that you can work with edt on different virtual consoles
		at the same time without interference
	  \item since the keytables are loaded permanently, they are
		remapped local so that edt-vt100-kbd runs transparently
		over the network now
	\end{itemize}
  \item [V1.03:] Included the {\tt -o} option to specify a different
		output file
\end{description}
\par
\section{Thanks}
I wish to thank:
\begin{itemize}
  \item Ken Thompson and Dennis Ritchie for giving us U{\sc nix}
  \item Linus Torvalds for providing us with one of the best
	operating systems in the world
  \item Richard Stallman and the staff from the Free Software
	Foundation for doing excellent work
  \item Rob Riepel (riepel@networking.stanford.edu), for making
	emacs work like EDT does. I would never have been able
	to write this code. His suggestions to {\tt edt-vt100-kbd}
	are appreciated
  \item Digital Equipment Corporation for supplying us with hard-
	and software in a quality that many other suppliers can
	only dream of
\end{itemize}
\par
\pagebreak
\appendix
\section{Disclaimer}
This software is put into the GPL. There is no guarantee whatsoever
that it does anything useful.
\par
This is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either this version, or (at your option)
any later version.
\par
This code is distributed in the hope that it will be useful,
but {\em without any warranty}; without even the implied warranty of
{\em merchantability} or {\em fitness for a particular purpose}. See the
GNU General Public License for more details.
\par
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.
\par
I would be glad to here from you if this piece of code was of any help
for you. Suggestions and bug reports are welcome. Please email to:
\par
\vspace{1em}
\centerline{\large\bf kschneid@biologie.uni-erlangen.de}
\par
\vspace{1em}
\section{Keypad Layout}
I've only implemented the keypad proper (i.\ e.\ numerical keys,
PF1, PF2, Enter \ldots). Their layout is as follows:
\par
\begin{center}
\begin{tabular}{|c|c|c|c|}
  \hline
	Gold & HELP & FndNxt & Del L\\
	 key & E-Help & Find &Undel L\\
  \hline
	Page  & Sect & Append &\\
	 Do   & Fill & Replace & Del W\\
  \cline{1-3}
	Forward & Reverse & Remove & Undel W\\
	Bottom &  Top  & Insert  &\\
  \hline
	Word  & EOL  & Char  &\\
	ChngCas & Del EOL & SpecIns & Enter\\
  \cline{1-3}
	\multicolumn{2}{|c|}{Line} &Select & Subs\\
	\multicolumn{2}{|c|}{Open Line} &Reset &\\
  \hline
\end{tabular}
\end{center}
\par
\vspace{1em}
Please see your genuine EDT documentation for further details.
\end{document}
