[net.sources] Emacs with EDT flavor

lynno@tekfdi.UUCP (Lynn Olson ) (04/12/84)

;This .emacs_pro file maps the keypad of a VT-Series terminal into a command
;set resembling the DEC EDT (tm) editor. Most of the unshifted functions are
;unaltered - removing only two EDT functions, PAGE and ENTER. These
;are redefined into PARAGRAPH and ENTER WINDOW. This file requires the
;installation of Goslings CMU-Emacs and the use of an ANSI X3.64 terminal
;(vt100 clone).

;BackSpace is used in the usual UNIX (tm) fashion to delete previous
;characters, leaving the Delete key to serve as the Beginning-of-Line. This is
;the reverse of the DEC EDT editor, true, but is preferable to having different
;delete keys in and out of Emacs. LineFeed is used for the EDT function of
;delete-previous-word.

;The shifted GOLD/Keys are mostly unaltered, with SPECINS replaced
;by ^\, UND W and UND C replaced by UND LWC. SUBS and RESET are eliminated.
;All of these keys are redefined as:

;UND W ->	: Visit Buffer
;UND C ->	: Visit File
;SUBS  ->	: Visit Shell
;SPECINS ->	: Copy Mark/Dot Region
;RESET ->	: Reset Window (return to window associated
;				with initial file)

;  New commands are GOLD/GOLD, which exchanges the dot and the mark.
;Other new commands are GOLD/keyboard pairs, which are mapped as follows:

;GOLD/up-arrow	: Current line to top of window.
;GOLD/down-arrow: Current line to bottom of window.
;GOLD/left-arrow: Backward sentence.
;GOLD/right-arrow: Forward sentence.
;GOLD/-		: Goto percentage of buffer.
;GOLD/=		: Goto line number.
;GOLD/`		: Display line number and character number.
;GOLD/i		: Move Mark/Dot region to selected file.
;GOLD/o		: Copy Mark/Dot region to selected file.
;GOLD/p		: Delete selected buffer.
;GOLD/[		: Move Mark/Dot region to selected buffer.
;GOLD/]		: Insert selected buffer at dot.
;GOLD/BackSpace	: List Buffers.
;GOLD/Delete	: Delete Window.
;GOLD/ \	: Split Window.
;GOLD/LineFeed	: Capitalize Word.
;GOLD/ <CR>	: Indent Newline.
;GOLD/ <space>	: Undo; press <space> to continue undoing.
;			(This also works in the shell window.)

;  The following commands alter the Emacs default key map. Aside from
;these changes, all other Emacs commands retain the documented bindings.
;
;  Delete	: Beginning-of-Line.
;  LineFeed	: Delete-Previous-Word.
;  ^Q		: Reserved for X-ON flow control.
;  ^S		: Reserved for X-OFF flow control.
;  ^Z		: Extended-Command, with prompts for different exits.
;  ^_		: Pause-Emacs. (Unix command "fg" will restart Emacs.)

;<insert formfeed here>
;          E  M  A  C  S  /  E  D  T     K  E  Y  P  A  D
;+---------------+---------------+---------------+---------------+
;|     GOLD      |   HELP KEY    | < FINDNEXT >  |   DEL LINE    |
;|     ----      |   --------    |   --------    |   --------    |
;| Swap Dot-Mark |Find in Context|     Find      |  Und L, W, C  |
;+---------------+---------------+---------------+---------------+
;| < PARAGRAPH > |   < SECT >    |     APPEND    |   DEL WORD    |
;|   ---------   |     ----      |     ------    |   --------    |
;|    Command    |   Fill Para   | Query-Replace |  Visit Buffer |
;+---------------+---------------+---------------+---------------+
;|    ADVANCE -> | <- BACKUP     |      CUT      |   DEL CHAR    |
;|    -------    |    ------     |      ---      |   --------    |
;|    Bottom     |     Top       |     Paste     |  Visit File   |
;+---------------+---------------+---------------+---------------+
;|   < WORD >    |     EOL       |    < CHAR >   |               |
;|     ----      |     ---       |      ----     |               |
;|   Chgcase     | Delete-to-EOL |      Copy     |  ENTER WINDOW |
;+---------------+---------------+---------------+  ------------ |
;|        < LINE  SCROLL >       |     SELECT    |  Visit Shell  |
;|          ------------         |     ------    |               |
;|           Open Line           |  Reset Window |               |
;+-------------------------------+---------------+---------------+
;      ADVANCE & BACKUP toggle the  < KEYS >  back and forth.
;
;            K  E  Y  B  O  A  R  D     C  O  N  T  R  O  L  S
;    +---------------+---------------+---------------+---------------+
;    |       ^       |       v       |     <----     |     ---->     |
;    |     -----     |     -----     |     -----     |     -----     |
;    |  Line-to-Top  |Line-to-Bottom |Begin Sentence | End Sentence  |
;    +---------------+---------------+---------------+---------------+
;    |       -       |       =       |       `       |  BACK SPACE   |
;    |     -----     |     -----     |     -----     |  ----------   |
;    | Goto Percent  |  Goto Line #  |  Show Line #  | List Buffers  |
;+---------------+---+-----------+---+-----------+---+---+-----------+---+
;|       P       |       [       |       ]       |       | DEL (now BOL) |
;|     -----     |     -----     |     -----     |       | ------------- |
;| Delete Buffer | Cut-to-Buffer |Paste-from-Buff|       |  Del Window   |
;+---------------+---------------+---------------+       +---------------+
;                                                        |       \       |
; ^X-^A		:EXIT & file initial buffer.		 |     -----     |
; ^X-^C		:QUIT & discard changes.		 | Split Window  |
; ^X-^F		:ALL buffers are filed; exit Emacs.	 +---------------+
;							 | LF (RUBOUT W) |
;Ctrl-^		:Enlarge Window.			 | ------------- |
; ^G		:Abort Command.                          |Capitalize Word|
; ^L		:Redraw Display.			 +---------------+
; ^T		:Transpose Characters.
; ^U		:Multiply Command (^U/25/LINE moves the dot 25 lines).
; ^Z		:EDT style exit.
; ^_		:Pause-Emacs (type "fg" to re-enter Emacs).
; ^\		:Insert control-character (Escape would be ^\-^[).
;
; ^X-^I		:Insert File at Dot (see GOLD/I).
; ^X-^W		:Write Named File from current buffer.
;
;ESC-?		:Apropos Command.
;ESC-r		:Replace String (all occurances in buffer).
;
;GOLD/ <space>	:UNDO; press <space> to continue, any other key to stop.
;GOLD/ <CR>	:Indent Newline with indentation level of previous line.
;GOLD/ Replace	:Type "n" to skip over, <space> to change, Ctrl-G to exit.
;GOLD/I		:Move Mark/Dot region to file (complements ^X-^I).
;GOLD/O		:Copy Mark/Dot region to file. Filenames kept in Help buffer.
;<insert formfeed here>
;				N O T E S
;
;	Use the GOLD/Find function by typing in the desired string, then
;pressing <CR>. GOLD/Find will seek the first occurance. To continue the
;search, press FINDNEXT. Press ADVANCE or BACKUP to change direction of search;
;FINDNEXT will remember the original string after a change of direction.
;(Warning: If you end the search string with the FINDNEXT key instead of <CR>,
;the Find function will work, but it will also deposit an unwanted "OR" in
;your text.)
;
;	GOLD/ <space>, the UNDO function, has the interesting ability to
;reverse the action of the UNDO function. To try this, type a sequence of
;numbers such as "1234567890". Press GOLD/ <space>, then hit the <space>
;bar several times. This will leave the string of numbers looking like
;this: "12345". Now, press <GOLD>/ <space> and hit the <space> bar several
;times. The string of numbers will grow larger again, reversing the action
;of the previous "undos". This property can be handy in overcoming the
;ill effects of leaving too much undone.
;
;	Visit Shell opens a window with a shell running in it. The shell
;window executes Unix commands by either typing them out or moving the
;the dot to a previous command-line and pressing <CR>. If you want to
;leave the shell window, use Enter Window or Reset Window. If you press
;Visit Shell again, the previous commands and responses will still be there.
;The dialogue in the shell window may be cut and pasted into other buffers,
;allowing you to capture the exact syntax of commands. The shell buffer
;is cleaned up when you leave Emacs.
;
;	If Emacs is invoked without a filename, it recalls the previous
;file and the state of the screen. However, ^X-^A and GOLD/Reset Window
;will work in a different way; both will ask if the current buffer is the
;one to be filed or windowed. The default <CR> for both is "yes".
;
;	The multiply-command (^U) can be used in several ways. If given
;a number following the ^U, it executes the following command "n" times.
;If the ^U is used without a number, it does the following command 4 times.
;Pressing ^U more than once will do the following command 4**^U times.
;For example:
;^U/25/LINE	=25 lines.
;^U/LINE	=4  lines.
;^U^U/LINE	=16 lines.
;^U^U^U/LINE	=64 lines and so on.


;DEC, VMS, VT-100, and EDT are trademarks of Digital Equipment Corporation.
;UNIX is a trademark of American Telephone & Telegraph.

(defun

;These functions delete lines, cursor-to-end-of-lines, words, and characters.
;The deleted text is moved to the LineBuffer.

	;This deletes the entire current line and allows chaining
	;similar to the ^K (kill-to-end-of-line) function. The
	;(chained) text is put in the LineBuffer and retrieved by
	;the GOLD/Und LWC keys.
	;
	(delete-current-line pass
	    (save-window-excursion; Preserve existing mark.
	    (setq pass 0); Loop counter.
	    (prefix-argument-loop; Allow ^U to multiply function.
		(beginning-of-line)
		(set-mark)
		(next-line)
		(if	(< 0 (+ (= 1 pass) (= -48 (previous-command))))
			(progn
				(append-region-to-buffer "LineBuffer")
				(erase-region)
			)
			(progn
				(delete-region-to-buffer "LineBuffer")
				(setq pass 1)
			)
		)
	    )
	    )
	    (setq this-command -48)
	)

	;This allows the Del EOL to have a chaining feature similar to
	;the Del L function above. It is chained with Del W and Del C.
	;
	(delete-to-eol
	    (save-window-excursion
		(if	(eolp)
			(progn
				(set-mark)
				(next-line)
				(end-of-line)
				(exchange-dot-and-mark)
			)
			(progn
				(set-mark)
				(end-of-line)
				(exchange-dot-and-mark)
			)
		)
		(if	(= -48 (previous-command))
			(progn
				(append-region-to-buffer "LineBuffer")
				(erase-region)
			)
			(delete-region-to-buffer "LineBuffer")
		)
	    )
	    (setq this-command -48)
	)

	;This deletes the current word. It may be chained with Del L,
	;Del EOL, previously deleted words, or previously deleted characters.
	;The words are parked in the LineBuffer.
	(delete-current-word pass
	    (save-window-excursion
	    (setq pass 0)
	    (prefix-argument-loop
		(set-mark)
		(forward-word)
		(if	(< 0 (+ (= 1 pass) (= -48 (previous-command))))
			(progn
				(append-region-to-buffer "LineBuffer")
				(erase-region)
			)
			(progn
				(delete-region-to-buffer "LineBuffer")
				(setq pass 1)
			)
		)
	    )
	    )
	    (setq this-command -48)
	)

	;This deletes the current character. It may be chained with Del L,
	;Del EOL, previously deleted words, or previously deleted characters.
	;The characters are parked in the LineBuffer.
	(delete-current-character pass
	    (save-window-excursion
	    (setq pass 0)
	    (prefix-argument-loop
		(set-mark)
		(forward-character)
		(if	(< 0 (+ (= 1 pass) (= -48 (previous-command))))
			(progn
				(append-region-to-buffer "LineBuffer")
				(erase-region)
			)
			(progn
				(delete-region-to-buffer "LineBuffer")
				(setq pass 1)
			)
		)
	    )
	    )
	    (setq this-command -48)
	)

	;Undelete Lines, Words, and Characters.
	(undelete-line
	    (prefix-argument-loop; Allow ^U to multiply function.
		(yank-buffer "LineBuffer")
	    )
	)

;These two functions add the Copy and Append function to the standard
;delete-to-killbuffer and yank-from-killbuffer.

	;GOLD/COPY. Copy mark-dot region to Kill buffer.
	(copy-to-killbuffer
		(save-window-excursion
			(copy-region-to-buffer "Kill\040buffer")
			(temp-use-buffer "Kill\040buffer")
			(message (buffer-size) " characters copied.")
		)
		(set-mark)
		(send-string-to-terminal "\e#>");Perform keyclick.
	)

	;APPEND function. Append mark-dot region to Kill buffer.
	(append-to-killbuffer
		(append-region-to-buffer "Kill\040buffer")
		(message "Appended.")
		(set-mark)
		(send-string-to-terminal "\e#>");Perform keyclick.
	)

;These two functions move or copy the Mark/Dot region to a file. They are
;complementary to the ^X-^I insert-file command. To keep track of new
;files, the prompted filenames are saved in the Help buffer, where they
;may be viewed by the user.

	;Move Mark/Dot region to a selected file. Rejects null filenames.
	(file-region writefile
		(setq writefile (arg 1 "Move Mark/Dot region to Filename: "))
		(if (= writefile "")
			(error-message "No filename.")
		)
		(copy-region-to-buffer "Kill\040buffer")
		(save-window-excursion
			(temp-use-buffer "Kill\040buffer")
			(write-named-file writefile)
(message (buffer-size) " characters moved to " writefile ".")
			(setq buffer-is-modified 0)
			(temp-use-buffer "Help")
			(insert-string (concat writefile "	"))
			(setq buffer-is-modified 0)
		)
		(erase-region)
	)

	;Copy Mark/Dot region to a selected file. Rejects null filenames.
	(copy-region-to-file writefile
		(setq writefile (arg 1 "Copy Mark/Dot region to Filename: "))
		(if (= writefile "")
			(error-message "No filename.")
		)
		(copy-region-to-buffer "Kill\040buffer")
		(save-window-excursion
			(temp-use-buffer "Kill\040buffer")
			(write-named-file writefile)
(message (buffer-size) " characters copied to " writefile ".")
			(setq buffer-is-modified 0)
			(temp-use-buffer "Help")
			(insert-string (concat writefile "	"))
			(setq buffer-is-modified 0)
		)
		(set-mark)
	)

;Trivia.

	;Alternate between capitalize-word and uppercase-word.
	(capitalize-or-upper
		(if	(= -6 (previous-command))
			(progn (case-word-upper) (setq this-command -3))
			(progn (case-word-capitalize) (setq this-command -6))
		)
	)

;Assorted cursor motion corrections and EDT emulations.

	;Move EOL downward if key is pressed repeatedly.
	(repeat-end-of-line pass
	    (setq pass 0); Loop counter.
	    (prefix-argument-loop; Allow ^U to multiply function.
		(if	(< 0 (+ (= 1 pass) (= -12 (previous-command))))
			(next-line)
		)
		(progn
			(end-of-line)
			(setq pass 1)
		)
	    )
	    (setq this-command -12)
	)

	;Move BOL downward if key is pressed repeatedly.
	(repeat-beginning-of-line pass
	    (setq pass 0)
	    (prefix-argument-loop; Allow ^U to multiply function.
		(if	(< 0 (+ (= 1 pass) (= -10 (previous-command))))
			(next-line)
		)
		(progn
			(beginning-of-line)
			(setq pass 1)
		)
	    )
	    (setq this-command -10)
	)

;As above, but these are affected by the advance-direction and
;backup-direction bindings.

	;WORD in the Advance mode.
	(next-word
	    (prefix-argument-loop; Allow ^U to multiply function.
		(forward-word)
		(forward-word)
		(backward-word)
	    )
	)

	;Scrolls the display and the cursor.
	(scroll-cursor-up
	    (prefix-argument-loop
		(beginning-of-line)
		(next-line)
		(scroll-one-line-up)
	    )
	)
	(scroll-cursor-down
	    (prefix-argument-loop
		(beginning-of-line)
		(previous-line)
		(scroll-one-line-down)
	    )
	)

	;Puts the cursor at the beginning of indented paragraphs.
	(next-paragraph
	    (prefix-argument-loop
		(next-line)
		(forward-paragraph)
		(previous-line)
		(if (eolp) (next-line))
	    )
	)
	(previous-paragraph
	    (prefix-argument-loop
		(backward-paragraph)
		(previous-line)
		(if (eolp) (next-line))
	    )
	)

	;Findnext in Advance mode.
	(findnext-advance
		(message "Continuing search ...")
		(prefix-argument-loop
			(search-forward "")
		)
	)

	;Findnext in Backup mode.
	(findnext-backup
		(message "Continuing reverse search ...")
		(prefix-argument-loop
			(search-reverse "")
		)
	)

;Implements the EDT toggle-switch action between ADVANCE and BACKUP keys,
;which controls the direction of a collection of cursor motions.

	;Set EDT Advance mode for cursor keys.
	(advance-direction
		(setq global-mode-string "  ADVANCE      ->")
		(bind-to-key "next-page" "\eOx")
		(bind-to-key "next-paragraph" "\eOw")
		(bind-to-key "next-word" "\eOq")
		(bind-to-key "forward-character" "\eOs")
		(bind-to-key "scroll-cursor-up" "\eOp")
		(bind-to-key "findnext-advance" "\eOR")
		(bind-to-key "search-forward" "\eOP\eOR")
	)
	;
	;Set EDT Backup mode for cursor keys.
	(backup-direction
		(setq global-mode-string "<-       BACKUP")
		(bind-to-key "previous-page" "\eOx")
		(bind-to-key "previous-paragraph" "\eOw")
		(bind-to-key "backward-word" "\eOq")
		(bind-to-key "backward-character" "\eOs")
		(bind-to-key "scroll-cursor-down" "\eOp")
		(bind-to-key "findnext-backup" "\eOR")
		(bind-to-key "search-reverse" "\eOP\eOR")
	)

;Two resetting functions.

	;Ctrl-L function. Redraw display and set keypad application mode.
	(redraw-crt-set-keypad
		(send-string-to-terminal "\e=")
		(redraw-display)
	)		

	;Reset Window to the initial file used at Emacs' invocation. If the
	;initial file can't be found, delete two spontaneous windows and
	;prompt the user. If recursive-edit is in use, decrease by one level.
	(reset-window
		(if (> (recursion-depth) 0) ;Find-in-context exit.
		    (exit-emacs)
		)
		(if (error-occurred
			(use-old-buffer (argv 1));Name of initial file.
		    )
		    (progn; Do these things if there is an error above.
		        (save-window-excursion
			    (temp-use-buffer "Help")
			    (temp-use-buffer "Buffer\040list")
			)
		        (delete-buffer "Help")
			(delete-buffer "Buffer\040list")
			(if (!= "n"	(substr
(get-tty-string "Do you want "(current-buffer-name)" as the only window? ")
					1 1))
			    (delete-other-windows)
			    (previous-window)
			) ;inner endif.
		    ) ;end progn.
		    (delete-other-windows) ;Do this if use-old-buffer succeeds.
		) ;outer endif.
	)

;Assorted exit modes.

	;^X-^A function. Switches to the initial buffer (if possible),
	;writes this to a file, resets VT-Series keypad application mode,
	;and exits Emacs.
	(exit
		(if (error-occurred
			(use-old-buffer (argv 1));Name of initial file.
		    )
		    (progn; Do these things if there is an error above.
			(if (!= "n"	(substr
(get-tty-string "Do you want to file "(current-buffer-name)" and exit? ")
					1 1))
			    (progn
				(write-current-file)
				(send-string-to-terminal "\e>")
				(exit-emacs)
			    )
			    (previous-window)
			) ;inner endif.
		    )
		    (progn ;Do this if use-old-buffer succeeds.
			(write-current-file)
			(send-string-to-terminal "\e>");Reset VT appl. mode.
			(exit-emacs)
		    )
		) ;outer endif.
	)

	;^X-^F function. Reset VT-Series keypad application mode & exit.
	(all
		(switch-to-buffer "LineBuffer")
		(delete-buffer "LineBuffer")
		(send-string-to-terminal "\e>")
		(write-file-exit)
	)

	;^X-^C and ^C function. Reset VT-Series keypad application mode & quit.
	(quit
		(if (< (recursion-depth) 1)
			(send-string-to-terminal "\e>")
		)
		(exit-emacs)
		(send-string-to-terminal "\e=")
	)

	;Pause Emacs and reset keypad application mode. Set when
	;Emacs is restarted.
	(pause
		(send-string-to-terminal "\e>")
		(pause-emacs)
		(send-string-to-terminal "\e=")
		(setq unlink-checkpoint-files 1)
	)

	;Prompted emulation of EDT line mode exits. An "exit" with a single
	;file tests for the presence of the initial file used with Emacs
	;invocation. If it is missing, the user is asked if the current
	;buffer should be saved.
	(ctrl-Z-command
		(error-occurred (execute-extended-command
(arg 1 "Exit choices: exit, quit, or all. Don't exit: nothing. Type: ")
		))
	)

    ;Displays line number, character number, and total characters.
    ;This MLISP function is from net.emacs.
    (display-line-number orig page line pagetop
	(save-excursion
	    (setq orig (dot))
	    (beginning-of-file)
	    (setq page 1)
	    (setq pagetop (dot))
	    (while
		(& (! (error-occurred (search-forward "\^L")))
		   (<= (dot) orig))
		(setq page (+ page 1))
		(setq pagetop (dot))
	    )
	    (goto-character pagetop)
	    (setq line 1)
	    (while
		(& (! (error-occurred (search-forward "\n")))
		   (<= (dot) orig))
		(setq line (+ line 1))
	    )
	)
	(message "Line " line 
	    (if (> page 1)
		(concat " in page " page)
		""
	    )
	    ", " (- (dot) 1) " of " (buffer-size) " characters"
	)
    )
); End of defun.

;Here's an improved version of line-to-bottom-of-window based on Hans
;Koomen's message of 30 Jul 83:

(error-occurred		; window-width is already defined in some versions
    (defun (window-width 79)))
(defun
    (line-to-bottom-of-window	lines2skip chars2skip physlines
	(setq chars2skip (- (window-width) 1))
	(setq lines2skip (window-height))
	(setq physlines  (+ 1 (/ (- (current-column) 2) chars2skip)))
	(setq lines2skip (- lines2skip physlines))
	(save-excursion
	    (while (> lines2skip 0)
		   (previous-line)
		   (end-of-line)
		   (setq physlines (+ 1 (/ (- (current-column) 2) chars2skip)))
		   (setq lines2skip (- lines2skip physlines)))
	    (if (< lines2skip 0)
		(next-line))
	    (line-to-top-of-window)
	)
    )
)

; ATON -- line oriented "fly-by" search capability for Unix-Emacs.
; By Jeff Shrager and Duane Williams: CMU.

; ATON prompts for an argument which is string to be located in the
; current buffer.  It makes a list of all the lines in that buffer
; that contain the specified string and then leaves the user in recursive
; edit in that list.  The user should place himself on some line of the
; file/list and then use ^C to end recursive edit mode.  This will cause
; him to be repositioned in the original buffer at the line selected
; from the summary list.  If the string entered is nil then THE EXACT
; SAME summary list is used.  It will not reflect changes in the file
; made since the last use of ATON and the cursor will be placed at the
; NEXT location.  This is useful for stepping through located lines
; rapidly in order.

; Changes made to ATON: Checkpointing is only turned off for Search
; String buffer, save-excursions are changed to save-window-excursions,
; repeated use of the summary list will cause the cursor to wrap around
; to the first line. GOLD/Reset may be used instead of ^C to exit (unlike
; ^C, this key is reverts to Reset Window at recursion-depth=0).

(defun
	(aton-lines-in-buffer count
	    (save-excursion
		(beginning-of-file)
		(setq count 0)
		(while (!(eobp))
		    (next-line)
		    (setq count (+ count 1))
		)
	    )
	    count
	)

	(aton-current-line line-number
	    (save-excursion
		(save-restriction
		    (set-mark)
		    (beginning-of-file)
		    (narrow-region)
		    (setq line-number (aton-lines-in-buffer))
		    (exchange-dot-and-mark)
		    (if (bolp)
			(setq line-number (+ 1 line-number)))
		)
	    )
	    line-number
	)

	(find-in-context s ln l tracking done rebuild-summary
	    (setq s (get-tty-string "Search context for: "))
	    (if (!= "" s)
		(setq rebuild-summary 1))
	    (setq tracking track-eol-on-^N-^P)	; Remember prev value
	    (setq track-eol-on-^N-^P 0)		; Don't track eol
	    (if rebuild-summary
		    (save-window-excursion		; Setup temp buffer
			(pop-to-buffer "String Search")
			(erase-buffer)
			(setq needs-checkpointing 0)	; No CKP files needed
		    )
	    )
	    (save-window-excursion
		(beginning-of-file)
		(set-mark)			; Init for narrow-region
		(setq ln 0)			; Init accumulator
		(setq done 0)
		(if rebuild-summary
			(while (! done)
			    (if (error-occurred (search-forward s))
				(setq done 1)
				(progn
				    (end-of-line); To pick up entire line
				    (narrow-region); Don't count lines twice
				    (setq ln (+ ln (aton-current-line)))
				    (set-mark); Copy line to temp buffer
				    (beginning-of-line)
				    (setq l (region-to-string))
				    (save-excursion
					(pop-to-buffer "String Search")
					(insert-string (concat ln ". " l))
					(newline)
				    )
				    (widen-region); Continue through file
				    (next-line)
				    (set-mark); Reset for narrow-region
				)
			    )
			)
		)
		(pop-to-buffer "String Search"); Show user the results
		(if rebuild-summary
			(previous-line)
			(progn
			    (next-line)
			    (if (eobp)
				(beginning-of-window)
			    )
			)
		)
		(delete-other-windows)
		(setq buffer-is-modified 0)
		(if (= 0 (aton-lines-in-buffer))
			(progn
				(delete-buffer "String Search")
				(error-message "Can't find it")
			)
		)
(message "Move cursor to the desired line, then press GOLD/Reset or ctrl-C.")
		(recursive-edit)
		(beginning-of-line)
		(forward-word)
		(set-mark)
		(beginning-of-line)
		(setq ln (region-to-string))
		(delete-window "Search String")
		(delete-window "Help")
		(delete-window "Buffer list")
	    )
	    (setq track-eol-on-^N-^P tracking)	; Restore old value
	    (goto-line ln)
	)
)

(load "goto.ml")

(setq scroll-step 1)
(setq track-eol-on-^N-^P 0)
(setq ctlchar-with-^ 1)
(setq quick-redisplay 1)
(setq wrap-long-lines 1)
(setq default-right-margin 79)
(setq default-case-fold-search 1)
(setq default-mode-line-format " %[%p of: %b%*	|%m|	%M%]")
(setq backup-before-writing 1)
(setq backup-by-copying-when-linked 1)
(setq silently-kill-processes 1)
(setq unlink-checkpoint-files 1)

;Mask off X-ON, X-OFF codes and bind keyboard control-keys
(bind-to-key "delete-previous-word" "\012")	;"LineFeed"
(bind-to-key "redraw-crt-set-keypad" "\014")	;"ctrl-L"
(bind-to-key "novalue" "\021")			;X-ON  control code
(bind-to-key "novalue" "\023")			;X-OFF control code
(bind-to-key "ctrl-Z-command" "\032")		;"ctrl-Z"
(bind-to-key "quote-character" "\034")		;"ctrl-\"
(bind-to-key "enlarge-window" "\036")		;"ctrl-shift-^"
(bind-to-key "pause" "\037")			;"ctrl-shift-_"
(bind-to-key "repeat-beginning-of-line" "\177")	;"Delete"
(bind-to-key "exit" "\^X\^A")			;File initial buffer & exit.
(bind-to-key "quit" "\^C")			;Depart Emacs & reset keypad.
(bind-to-key "quit" "\^X\^C")			;Depart Emacs & reset keypad.
(bind-to-key "all" "\^X\^F")			;File all buffers and exit.

;Bind keyboard arrow keys
(bind-to-key "previous-line" "\e[A")		;"up-arrow"
(bind-to-key "next-line" "\e[B")		;"down-arrow"
(bind-to-key "backward-character" "\e[D")	;"left-arrow"
(bind-to-key "forward-character" "\e[C")	;"right-arrow"

;Bind keypad keys
(bind-to-key "describe-key" "\eOQ")		;HELP	"PF2"
(bind-to-key "delete-current-line" "\eOS")	;DEL L	"PF4"
(bind-to-key "append-to-killbuffer" "\eOy")	;APPEND "9"
(bind-to-key "delete-current-word" "\eOm")	;DEL W	"-"
(bind-to-key "advance-direction" "\eOt")	;ADV	"4"
(bind-to-key "backup-direction" "\eOu")		;BAK	"5"
(bind-to-key "delete-to-killbuffer" "\eOv")	;CUT	"6"
(bind-to-key "delete-current-character" "\eOl")	;DEL C	","
(bind-to-key "repeat-end-of-line" "\eOr")	;EOL	"2"
(bind-to-key "set-mark" "\eOn")			;SELECT	"."
(bind-to-key "next-window" "\eOM")		;ENTER	"ENTER"

;Bind GOLD/Keyboard keys
(bind-to-key "list-buffers" "\eOP\010")			;"BackSpace"
(bind-to-key "capitalize-or-upper" "\eOP\012")		;"Linefeed"
(bind-to-key "newline-and-indent" "\eOP\015")		;"Return"
(bind-to-key "new-undo" "\eOP\040")			;"Spacebar"
(bind-to-key "goto-percent" "\eOP\055")			;"-"
(bind-to-key "goto-line" "\eOP\075")			;"="
(bind-to-key "delete-region-to-buffer" "\eOP\133")	;"["
(bind-to-key "split-current-window" "\eOP\134")		;"\"
(bind-to-key "yank-buffer" "\eOP\135")			;"]"
(bind-to-key "display-line-number" "\eOP\140")		;"`"
(bind-to-key "file-region" "\eOP\i")			;"i"
(bind-to-key "copy-region-to-file" "\eOP\o")		;"o"
(bind-to-key "delete-buffer" "\eOP\p")			;"p"
(bind-to-key "delete-window" "\eOP\177")		;"Delete"
(bind-to-key "line-to-top-of-window" "\eOP\e[A")	;"up-arrow"
(bind-to-key "line-to-bottom-of-window" "\eOP\e[B")	;"down-arrow"
(bind-to-key "backward-sentence" "\eOP\e[D")		;"left-arrow"
(bind-to-key "forward-sentence" "\eOP\e[C")		;"right-arrow"

;Bind GOLD/Keypad keys
(bind-to-key "exchange-dot-and-mark" "\eOP\eOP");Gold		"PF1"
(bind-to-key "find-in-context" "\eOP\eOQ")	;Help		"PF2"
(bind-to-key "undelete-line" "\eOP\eOS")	;Und LWC	"PF4"
(bind-to-key "execute-extended-command" "\eOP\eOw") ;Command	"7"
(bind-to-key "justify-paragraph" "\eOP\eOx")	;Fill		"8"
(bind-to-key "query-replace-string" "\eOP\eOy")	;Replace	"9"
(bind-to-key "pop-to-buffer" "\eOP\eOm")	;Visit Buffer	"-"
(bind-to-key "end-of-file" "\eOP\eOt")		;Bottom 	"4"
(bind-to-key "beginning-of-file" "\eOP\eOu")	;Top		"5"
(bind-to-key "yank-from-killbuffer" "\eOP\eOv")	;Paste		"6"
(bind-to-key "visit-file" "\eOP\eOl")		;Visit File 	","
(bind-to-key "case-word-invert" "\eOP\eOq")	;Chgcase	"1"
(bind-to-key "delete-to-eol" "\eOP\eOr")	;Del EOL	"2"
(bind-to-key "copy-to-killbuffer" "\eOP\eOs")	;Copy		"3"
(bind-to-key "newline-and-backup" "\eOP\eOp")	;Open L		"0"
(bind-to-key "reset-window" "\eOP\eOn")		;Reset Window	"."
(bind-to-key "shell" "\eOP\eOM")		;Visit Shell	"ENTER" 

;Set VT-Series keypad application mode, initialize direction, and
;prevent the two temporary buffers from being checkpointed.
(send-string-to-terminal "\e=")
(advance-direction)
(save-window-excursion
	(temp-use-buffer "LineBuffer")
	(setq needs-checkpointing 0)
	(temp-use-buffer "Kill\040buffer")
	(setq needs-checkpointing 0)
)

;End of .emacs_pro file.