vm: EMACS' mail reader

Baonian Hu sez:

set record=$HOME/copy in the .mailrc file will keep a copy of all mail messages that I sent out.

I know I could always cc: myself to get the same effect, but I am lazy.

Ahhh! Put this in your .emacs:

(setq mail-archive-file-name "~/.FCC")

All mail you send will also end up in a file called ".FCC" in your home dir. Obviously, change "~/.FCC" to "~/copy" or whatever, to name the file. You will notice a new header when sending mail, should be fairly self explanatory. It's not VM-specific, but VM knows how to use it.

Enjoy, Karl

Hi! I wonder, is there any way to route mail? I receive a lot of big mail messages from the Gaynet group, and i tire of saving each individual message as a file so that i can put them in their own directory...surely there has to be a better way? any help would be appreciated..

Well, we first need to know how you read mail :-). I am assuming that you use VM in Emacs. A line like this in your .emacs will make it so that when you hit "s" to save a message, it will default to the appropriate folder so you only have to hit RET after you type "s". I don't know how to make it automatically put a message in a folder without your typing "s" in the VM menu (on the line with the message); anyone else on help know how? Anyway, try this in your .emacs:

(setq vm-auto-folder-alist
   '(("from:" ("Gaynet@wherever.they.are" . "~/folder.name"))
     ("From:" ("Gaynet@wherever.they.are" . "~/folder.name"))))
By the way, the term folder just means "A file full of mail messages that you can visit with the "v" command in VM." Folders are always appended to when you save a message in them, nothing already in the folder is ever overwritten.

If you type "A" in VM, all messages will automatically be archived in the correct folders, if your vm-auto-folder-alist exists and there are messages matching it in your mailbox. Thanks to Jen Mankoff for pointing this out!

Karl

How do I automatically include a .signature file at the end of mail messages I send out? I like to send mail in emacs. If I can't do it automatically, how do I read a file into my emacs mail buffer?

First, make your .signature file and save it in your root directory. Then, when writing your mail message in emacs, type Ctrl-c Ctrl-w to include your .sig file. FYI, Ctrl-c Ctrl-w is the binding for Esc-x mail-signature.

To insert a file into the current buffer, try C-x i.

Jim

Sorry for the silly question, but how do you change the default mail folder in VM to something other than "~/mbox"?

Don't be sorry, we're here for silly questions. Try this in your .emacs:

(setq vm-primary-inbox "~/my_mbox")

or

(setq vm-primary-inbox "~/my_mail_directory/my_mbox")

even.

Karl

Silly question, but how do I open the file mbox?

Not silly at all--in fact, whenever you have a question like this, no matter how silly it seems, if you can't figure it out yourself, you should send mail to help (help AT cs.oberlin.edu), a mailing list of people (like me) who like answering all kinds of computer-related questions.

is it more mbox?

Yes, you can look at the mbox file by typing "more mbox" at the prompt, but since it probably has lots of mail messages with krunky headers in it, it will probably seem rather confusing. Instead, if you want to read, delete or move messages around, the best way to do that is to run Emacs, and then type "M-x vm" (that is, hold down the meta key and type an "x", release the meta key, then type a "v", an "m", and finally a return). You are now running VM, the best way I know of to read mail. Type an "h", to get a summary of the contents of your mbox. Emacs should display a buffer called "mbox Summary" that will look something like this:


-> 1    R  Karl Fogel        Jul 18   73/3251  "Re: From the .plan of a sysadm$
   2   F   Andrew Cherry     Jul 18   19/574   "Re: So THAT's how hard drives $
   3       Marcus Speh       Jul 20   66/3253  "default.cc in Chapter 4"
   4       Kennis Koldewyn   Jul 25    0/0     "Haskell_Thomson@qmgate.cc.ober$
   5       Karl Fogel        Aug  1   12/606   "Re: losing"
   6    R  Karl Fogel        Aug  1   17/795   "curious: why does Scheme->C ne$

The little arrow at the left shows which message you are looking at; the text of the message should be visible in a buffer called "mbox". Here are some of the more useful commands you can use in VM (type the letter in the left column to get the effect described in the right column):


   n - go to next message
   p - go to previous message
   N - like `n' but will go to messages you have marked for deletion
   P - like `p' but will go to messages you have marked for deletion
   h - summarize folder contents

 SPC - scroll forward a page (if at end of message, then display next message)
   b - scroll backward a page

   d - delete message (flag as deleted)
   u - undelete message

   r - reply (only to the sender of the message)
   R - reply with included text for current message
   z - forward the current message

   q - quit VM, deleted messages are expunged, folder saved to disk

There are other commands too--type "C-h m" when your text cursor is in one of the messages, and Emacs will make a buffer called "*Help*" that will display documentation about VM.

If you have any problems getting VM to work, or any more questions, please send mail to help; I'll respond (unless someone silly like Karl beats me to it).

- Kennis

Jen Mankoff writes:

When I gzip mail files, vm has no problem reading them, but when I save messages to those files (using vm) it saves them in text format. Unfortunately gunzip then assumes that the end of the file is garbage, so when the files get unzipped all of the messages saved on the end of them in text format disappear. Now maybe it's possible to change vm's save command using a hook or something so that it will save in gzipped format somehow and then if _all_ of your mail were always gzipped things would be ok ....

VM has a variable visit-when-saving; when set to true, it loads a file into a buffer and then writes to it, rather than writing to the file directly. This solves the problem jen is mentioning. However, it leaves two problems in it's wake. The first is that the buffer is not automatically written to, which creates the hassle of saying "yes, please save this" when you quit emacs, and the danger of loosing the changes completely in the event of a system crash during your session. The second is that it also writes a ~ backup file; I set make-backup-files to nill in my vm-mode-hooks, but that doesn't help if you are saving the buffers after vm has quit.

Here's another space-saving vm-related question. The SunOS version of /usr/ucb/mail has a lovely flag called alwaysignore; when set, not only does mail strip annoying headers that you tell it to strip (like Resent-To, resent-date, Message-ID, etc... - all those message headers that tell you nothing but can fill up multiple screens if your message came from a mailing lits), but it also strips those headers for good when saving to a folder. This can save serious amounts of space, depending on the type of mail you get. Is there any way to get analagous behavior in VM? - Ian

P.S. I realize that these questions don't have much relevance with the 24meg quota Chuck pampers us with, but some of the machines I work on at UC have frighteningly little disk-space - as a general rule, I have more free quota at Oberlin than free *disk-space* on the math machines here at Chicago!

Here's the deal. Put this in your .emacs:

----------------------------------------------------------------------
(add-hook 'mail-setup-hook 'mail-abbrevs-setup)
----------------------------------------------------------------------

(there's an autoload for the "mailabbrev" package, so this will work without any other support code). Now, when you're in mail and type a mail alias on any of the To, CC, BCC, or related lines, the alias will automatically be expanded when you hit a space after the name. For example, when I'm typing a letter to mom, I do:

C-x m m o m 

Before...

To: mom

After...

To: cragg002@maroon.tc.umn.edu

Neat, eh?

If it turns out you don't want the alias, just do M-x undo.

Have fun.

Brian Postow sez:

how come when I reply to something in vm, it just puts the previous subject and not Re: previous subject? this seems to be common at occs, (ie I noticed it on Kevin's reply too)... what is the setq to change this?

You need to do:

(setq vm-reply-subject-prefix "Re: ")

After a bit of querying here at Chicago, I got the following:

Below is one posting from a thread on this question that was in the VM mailing list not too long ago (which is equivalent to a newsgroup whose name I can't quite come up with).

Why doesnt vm clear deleted messages?

The correct way is:


(add-hook 'vm-mode-hook
  (function
   (lambda()
     (define-key vm-mode-map "Q" 'vm-quit)
     (define-key vm-mode-map "q" "#Q"))))
P.S. Feel free to check out my .emacs for other vm preferences stuff.
>From: shriram@asia.cs.rice.edu (Shriram Krishnamurthi)
>To: johnl@cs.indiana.edu, kold@asia.cs.rice.edu
>Subject: VM
>Date: Mon, 12 Dec 94 21:34:06 CST
>
>Yawl,
>
>This simply isn't happening.
>
>Essentially, I am unable to get VM to recognize my include prefix.  I
>moved my entire hook contents to the top-level, as I saw you both had
>done in your .emacs, and this gave me some of my settings (such the
>vm-primary-inbox), but not the rest.  Eval'ing the names shows them to
>be bound to the right values.
>
>In summary, I want to know how to do the following things:
>
>--  Get my include prefix to be "> ".
>--  Have a Date: header generated for outgoing messages.
>--  Have my attribution string not contain quotes, as in,
>
>      John Lacey said:
>
>    as opposed to
>
>      "John Lacey" said:
>
>    I currently have
>
>      vm-included-text-attribution-format "%F said:\n"

        I have the following four things in my .emacs.  As I recall,
the bottom three were all necessary in order to get ">" quoting,
though I'm not sure now if that's really the case (like, why does
`indent-prefix' matter?)

(setq vm-included-text-attribution-format "%F sez:\n")
(setq vm-included-text-prefix ">")
(setq indent-prefix ">")
(setq mail-yank-prefix ">")



There is a better way to do aliases from Emacs --- mailabbrev.el.
Using this package, there's no confusion; the address you put in your
header is the address the mail goes to, and there's no invisible
munging going on.  If you type an aliased name into the mail header,
it gets instantly replaced, right before your eyes, with the full
address.  If you didn't mean to use the alias, you just hit "undo".
You don't have to worry whether you spelled the alias correctly,
whether you actually got around to defining that alias at all,
etcetera. 

How to use it: Here's the deal. Put this in your .emacs: ---------------------------------------------------------------------- (add-hook 'mail-setup-hook 'mail-abbrevs-setup) ---------------------------------------------------------------------- (there's an autoload for the "mailabbrev" package, so this will work without any other support code). Now, when you're in mail and type a mail alias on any of the To, CC, BCC, or related lines, the alias will automatically be expanded when you hit a space after the name. For example, when I'm typing a letter to mom, I do: C-x m m o m Before... To: mom After... To: cragg002@maroon.tc.umn.edu Neat, eh? If it turns out you don't want the alias, just do M-x undo.


Back to the UnixHelp: Local Section Index
jbayes@cs.oberlin.edu, public AT cs.oberlin.edu