From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1164f8,5b05b151ea0bd2d5,start X-Google-Attributes: gid1164f8,public X-Google-ArrivalTime: 1994-08-05 07:17:38 PST Path: bga.com!news.sprintlink.net!hookup!yeshua.marcam.com!MathWorks.Com!news.duke.edu!godot.cc.duq.edu!toads.pgh.pa.us!newsfeed.pitt.edu!vms.cis.pitt.edu!bschor From: bschor@vms.cis.pitt.edu Newsgroups: comp.sys.dec Subject: VMSMail/EDT macro (thanks) Date: 5 Aug 94 09:53:59 EDT Organization: University of Pittsburgh Message-ID: <31tgak$nea@usenet.srv.cis.pitt.edu> NNTP-Posting-Host: vm3.cis.pitt.edu Dear Colleagues, I recently wanted to learn how to enhance VMS mail to simplify two tasks: implementing a "quoting" facility (whereby existing text, typically a message to which you are REPLYing, or a message you are FORWARDing, has a symbol, say ">", inserted before every line to distinguish the "old" message from "new" comments you may add), and adding a "signature" facility (to permit you to easily append a multi-line signature to your messages). I wanted routines which would be fairly simple (so that computer-naive users of e-mail could use them with little difficulty). I knew that u**x mail utilities have these facilities, but was steering my users to VMS because I felt the overall system was more friendly and less intimidating (e.g. HELP actually gets you help!). I received several useful replies. The first was from my local Faculty Computer Consultant, Richard Whitmore, who forwarded to me a combined DCL + EDT macro utility written by James Ralston Crawford. This inspired me to investigate EDT macros more carefully. I received two such macros, one from Bob Firestine, and a second (with very helpful comments) from Don Stokes (thanks to Ken Fairfield for digging out his name and e-address). When I asked for help, I promised that if I "solved" my problem, I'd publish the solution. Here it is, along with copious notes that explain how everything works ... Lines in LOGIN.COM -- $! Ensure EDT uses our initialization file $! $ edt :== "edit/edt/command=sys$login:edtini.edt" $! $! Set up VMS Mail using EDT editor $! $ mail :== mail/edit=(send,reply=extract,forward) $! The redefinition of the MAIL command causes VMSMail to use EDT as its default editor for messages you SEND, REPLY to, or FORWARD, instead of using VMSMail's single-line editor. Note that if you are dealing with EDT-unaware users, you can simply tell them not to use the keypad or function keys, to use the arrow keys for moving around the text, use delete to delete characters, and when done, type ^Z (to get the asterisk) and then EXIT. This gives them the benefit of a full-screeen editor, most specifically the ability to correct an error on the "previous line", and the ability to have automatic line wrapping as they type. The "REPLY=EXTRACT" option causes the message to which you are REPLYing to be included in your reply. If you do not want this feature, replace the switch with "/edit=(send,reply,forward)". EDTINI.EDT DEFINE MACRO QUOTE FIND BUFFER QUOTE insert;set quiet insert;change; er -l 9999(i>^Z -2l) ex insert;set noquiet FIND LAST DEFINE MACRO SIGNATURE FIND BUFFER SIGNATURE insert;change; desel er sel ^m ex insert;include sys$login:signature.txt end insert;change; -sr ex FIND LAST DEFINE MACRO HEADERKILL FIND BUFFER HEADERKILL insert;change; br +2par -"From:" +par dbr ex FIND LAST DEFINE KEY GOLD Q AS 'EXT QUOTE.' DEFINE KEY GOLD S AS 'EXT SIGNATURE.' DEFINE KEY GOLD H AS 'EXT HEADERKILL.' SET WRAP 75 SET MODE CHANGE This is an "initialization macro" for EDT. As I learned to my chagrin, EDT has three (!) editing "modes", called Line Mode, Keypad Mode, and NoKeypad Mode. The usual full-screen editor is running in Keypad Mode; macros (such as EDTINI) run in Line Mode. The above macro has three parts. The first part defines three new macros, QUOTE, SIGNATURE, and HEADERKILL. The second part assigns these macros to Keypad keys, so they are available when editing. The third part sets up and switches to Keypad Mode. To define a macro, you issue the DEFINE MACRO command, switch to a buffer (with FIND BUFFER) named after the macro, insert the macro commands (with an insert; command), and finally switch back to the main buffer (with FIND LAST). The macro QUOTE works as follows: The first command, "set quiet", is a Line Mode command to turn off the beeper (the macro will deliberately cause an error; turning off the beeper is designed to soothe the user's nerves by not drawing his/her attention to it). The next command changes to NoKeypad Mode ("change;"), goes to the end of the message ("er", stands for End Range), backs up a line ("-l") so as to be positioned before the last line in the message, and then repeats (up to 9999 times) the commands to insert a ">" character ("i>^Z") and back up two lines, which places you at the start of the previous line. During the course of executing this command (assuming the message doesn't have >9999 lines in it), you will back up to the top of the message, hit an "error", and stop executing the loop. The final command in the line ("ex") pops you out of NoKeypad Mode and back into Line Mode for the next command. The last command ("set noquiet") turns the beeper back on, so if the user makes an editing error in modifying the message, there will be an audible notification. When this command is executed, the contents of the entire editing buffer will have the symbol ">" placed before every line; the cursor will be left at the top of the message, allowing you to add reply text (unmarked by the quote symbol, ">") as you wish. Note that if you wish to remove header information from the message before replying, you may want to do that before quoting the text. Also, if you want to add a signature to the message, you should do this after quoting. If you wish to change the quote character from ">" to something else (":" is used by some), simply change the character in the middle line defining the QUOTE command. Also, if you want to leave the cursor at the end of the quoted message instead of at the beginning, and an "er" command before the "ex" command on the middle line. The SIGNATURE macro works as follows: The first command changes to NoKeypad Mode, turns off text selection ("desel"), moves to the end of the message, selects text ("sel") to remember where it is, adds a blank line ("^m"), and returns to Line Mode. The next line adds in ("include") a file called "signature.txt" which is in your default login directory, and places it at the end of the message ("end"). The final line jumps you back to the remembered selection location, at the end of the message but before the signature ("-sr", -Select Range). Note that you have to create the SIGNATURE.TXT file separately, filling it with whatever information you want to use to "sign" your e-mail messages. The HEADERKILL macro is designed to delete the header information that typically appears at the top of an e-mail message. If used, it should be done before "quoting" the message in reply, as it depends on finding blank lines separating header information from the message body. It will correctly deal with both simple VMSMail headers (which consists of "From:", "To:", "CC:", and "Subject:" headers), and more complex (u**x headers?) typical of mail coming in from the Internet. The macro consists of a single command which works like this: first, change to NoKeypad Mode. Start at the beginning of the message ("br", Begin Range) and move down 2 paragraphs (+2par), where a paragraph, by default, is signalled by two carriage returns, creating a blank line. This should place you past both the VMS and Internet headers. Now back up until you encounter the string "From:" (-"From:"), which occurs in both styles of header. Go forward again a paragraph ("+par"), which should now put you at the end of the (one or two paragraph) header. Delete from where you are to the beginning of the message ("dbr"), which deletes the headers, and return to Line Mode ("ex"). Now all the macros are defined, and are available as Line Mode commands. To make them available as commands in Keypad Mode, they are assigned to the keys "Gold Q" (for QUOTE), "Gold S" (for Signature), and "Gold H" (for HEADERKILL), where "Gold" is the PF1 key on the keypad (well, the naive user will have to learn a little EDT lore to use these macros, I guess). The commands to define the keys are all of the form "EXT command.", where EXT means the following is a Line Mode command, and the period means "do it now". The final lines of the macro enable line wrap at column 75, and change the editing mode to Keypad. [I will now type Gold S, which should add my Signature File to this message I am creating ...] Bob Schor (Robert H. Schor, Ph.D.) Associate Professor Department of Otolaryngology (412) 647-2116 Univ. of Pittsburgh Medical School bschor@vms.cis.pitt.edu 200 Lothrop Street bschor+@pitt.edu Pittsburgh, PA 15213