[comp.emacs] MicroEmacs' $readhook

wsincc@eutrc3.urc.tue.nl (Wim van Dorst) (07/21/89)

Hello Everybody,

I have set up as indicated in the manual, the proper things in
order to use MicroEmacs as my mail-editor. This works great sofar.

I have made a file mail.rc to use as startup file while using
MicroEmacs as mail-editor. It makes use of $writehook to add
my signature to the typed-in letter. I now want it to insert
things like "> " in front of each line of the letter I am
replying to, using $readhook. I have in mail.rc this:

23	store-macro
	set %rctmp &sin $cfname "."
	set %rctmp &mid $cfname &add %rctmp 1 5
	!if &seq %rctmp "rc"
		!return
	!endif
	write-message "You may reply to this file"
!endm
set $readhook execute-macro-23

When I open a letter (Mail, send, me, subject) it gives me an
empty file and no message. When I change the write-message to
insert-string ">" it gives an empty file and the cursor keeps
blinking behind the message "New File". It cannot be moved
anywhere anymore and I have to turn off my terminal. When I put in
the line replace-string "~n" "~n> " which was my original idea, I
get the same results.

How come I don't get the results I expect? Is it something I have
not yet understood about the use of the $readhook, or is it a
bug, or....?

I hope to see this discussed in this newsgroup, please.

Met vriendelijke groeten,  Wim van Dorst
(wsincc@tuerc3.urc.tue.nl or wsincc@tuerc3.uucp)

nwd@j.cc.purdue.edu (Daniel Lawrence) (07/24/89)

In article <809@eutrc3.urc.tue.nl> wsincc@eutrc3.urc.tue.nl (Wim van Dorst) writes:
>Hello Everybody,
>
>I have set up as indicated in the manual, the proper things in
>order to use MicroEmacs as my mail-editor. This works great sofar.
>
>I have made a file mail.rc to use as startup file while using
>MicroEmacs as mail-editor. It makes use of $writehook to add
>my signature to the typed-in letter. I now want it to insert
>things like "> " in front of each line of the letter I am
>replying to, using $readhook. I have in mail.rc this:

	[Macro Deleted]

>When I open a letter (Mail, send, me, subject) it gives me an
>empty file and no message. [More confusion..]

>How come I don't get the results I expect? Is it something I have
>not yet understood about the use of the $readhook, or is it a
>bug, or....?

	$readhook executes on the new buffer BEFORE the file is read
in.  It is meant primarily to allow you to set up an environment for a
file (by looking at it's file name or extention) before reading it in. 
To do what you want, it seems simple enough to just set up a command to
read the file in and then do the quoting.  For example:

store-procedure	mailread

	find-file @"Mail file to read: "
	beginning-of-file
	insert-string "> "
	replace-string "~n" "~n> "
	beginning-of-file
	unmark-buffer
!endm
macro-to-key mailread ^XR

(This is not tested.....)  So, when you want to read a mail file in
order to replay, just strike the ^X-R command, or build in a call to
this inside your mail macroes.

>I hope to see this discussed in this newsgroup, please.
>
>Met vriendelijke groeten,  Wim van Dorst
>(wsincc@tuerc3.urc.tue.nl or wsincc@tuerc3.uucp)

			Daniel Lawrence  voice: (317) 742-5153
					  arpa:	dan@midas.mgmt.purdue.edu
				The Programmer's Room 
				Fido: 1:201/10 - (317) 742-5533