[net.emacs] Novice to Novice Questions

mr@isrnix.UUCP ( Michael Regoli ) (08/11/84)

I was glad to see some recognizable questions recently
brought to net.emacs.  I guess I was waiting for someone
to "break the ice."  

I too am baffled by the execution of mlisp "programs"
while in emacs.  I found the manual quite cryptic in
describing the uses of mock lisp programs.  Personally,
I am looking for some mlisp to do a "replace" rather than
the quite cumbersome delete-insert sequence that I have to
go through on our version.

As a courtesy, can the novice please post the responses
he receives?  Or, better yet, maybe the person who
answers the question could post to net.emacs for all to see.

This could get exciting!

Thanks for listening.


-- 
           .:.
           /.\                Michael Regoli
          '|-|`       ...ihnp4!inuxc!iuvax!isrnix!mr

andrew@orca.UUCP (08/19/84)

[Nuke Bill's clone!]

	"I am looking for some mlisp to do a "replace" rather than the
	quite cumbersome delete-insert sequence that I have to go
	through on our version."

Here's a function which implements "overwrite mode", in which a
non-control character replaces the one at the cursor, rather than being
inserted there.  Of course, it is for Gosling/Unipress emacs.

  -- Andrew Klossner   (decvax!tektronix!orca!andrew)      [UUCP]
                       (orca!andrew.tektronix@rand-relay)  [ARPA]

; overwrite-mode.ml: Wordstar-like insert/overwrite mode

; To switch between modes, bind "insert-toggle" to a key and hit that key.
; (WordStar users might choose to bind this function to ^V.)
; Alternatively, bind "overwrite-mode" to one key and "insert-mode" to
; another, then use those two keys to switch between modes.
; The current mode is part of the highlighted mode line at the bottom
; of the window; "Normal" for insert mode, "Overwrite" for overwrite
; mode.

(setq-default insert-mode-flag 1)
(declare-buffer-specific insert-mode-flag)
(defun (self-overwrite
	(if (! (| (eobp) (eolp)))
		(if (| (!= 9 (following-char)) (= 0 (% (current-column) 8)))
			(delete-next-character)
			)
		)
	(insert-character (last-key-struck))
	))
(defun (tab-overwrite
	(if (| (eobp) (eolp))
		(insert-character 9)
		(progn
			(forward-character)
			(while (&
					(! (| (eobp) (eolp)))
					(!= 1 (% (current-column) 8))
					)
				(forward-character)
				)
			(if (!= 1 (% (current-column) 8))
				(insert-character 9)
				)
			)
		)
	))
(defun (argument-prefix-overwrite c i f1 f2
	(setq i 4)		; i is number being assembled
	(setq f1 1)		; f1 is "continue looping" flag
	(setq f2 0)		; f2 is "digit seen" flag
	(while f1
		(setq c (get-tty-character))
		(if (= c 21)
			(setq i (* i 4))
			(if (& (<= '0' c) (<= c '9'))
				(if f2
					(setq i (+ (* i 10) (- c '0')))
					(progn
						(setq i (- c '0'))
						(setq f2 1)
						)
					)
				(setq f1 0)
				)
			)
		)
	(push-back-character c)
	(return-prefix-argument i)
	))
(defun (overwrite-mode i
	(local-bind-to-key "tab-overwrite" "\^I")
	(local-bind-to-key "argument-prefix-overwrite" "\^U")
	(setq i 32)
	(while (< i 127)
		(local-bind-to-key "self-overwrite" i)
		(setq i (+ i 1))
		)
	(setq insert-mode-flag 0)
	(setq mode-string "Overwrite")
	(novalue)
	))
(defun (insert-mode
	(remove-all-local-bindings)
	(setq insert-mode-flag 1)
	(setq mode-string "Normal")
	(novalue)
	))
(defun (insert-toggle
	(if (= insert-mode-flag 0)
		(insert-mode)
		(overwrite-mode)
		)
	(novalue)
	))
(novalue)