6. Happy refiling

When you come to receive hundreds of messages in a day(don't you believe
it?), refiling messages becomes a very tough job. Mew neatly guesses
default folders where the message is supposed to be refiled when you
type `o'. You can see an example below.

Folder name (+work/mew-dist): +

If the default value in () is proper, just type `RET'. The messages
will be marked with `o' if its refiling folders are decided.

As you know, the more excellent refiling guess algorithms become, the
less user's job troublesome. Mew provides you with the following rules.

6.1 Guess by mailing-list folders

Many users tend to refile messages destined to a mailing-list to a
folder whose name is the same as the mailing-list. Mew provides a
mechanism to guess a mailing-list folder for messages destined to
mailing-lists.

Suppose that you have a folder named +misc/pooh-lovers. The following
message is probably to be refiled to this folder.

To: pooh-lovers@mew.org

Likewise, Mew searches a matching folder forward with addresses on To:
and Cc:. There are many people who don't use recursive folders. With
Mew, however, you would not be smart if you don't use it.

Smart users may wonder that they get a trouble in the following
situation where private addresses are on To: or Cc:.

To: piglet@mew.org
Cc: pooh-lovers@mew.org

Since pooh is a member of pooh-lovers, he receives this message. But he
has a folder for his friend, pooh. So, +from/piglet may be chosen.

To avoid this, Mew allows you to specify which folders are to be
ignored. The default is +from. So, please take a convention to refile
personal messages under +from.

When Mew guesses a candidate by the folders, it asks you:

Folder name (+misc/pooh-lovers): +

Just type `RET' if the default is exactly what you want.

If you specify a new folder with `o', the folder is created and
added to the folder list to be used for guess. Convenient, isn't it?

The function name to provide this feature is
`mew-refile-guess-by-folder'.

6.2 Guess by user defined rules

There are some cases where the refile guess mechanism by folders doesn't
work as you wish. For example, for both a message whose To: is
staff@mew.org and another message whose To: is staff@iijlab.net, the
same folder would be selected with guess by folders(e.g. "+net/staff").
So, Mew allows you to define your own rules explicitly.

6.3 Guess by thread

Mew provides a mechanism to guess a folder where the parent message of a
current message was refiled before.

For example, pooh, piglet, and roo had a chat to go and get honey. So,
pooh made +project/honey then refiled the message to it. The further
messages, if they are properly replied, they are supposed to be refiled
to +project/honey.

Information that which folder was chosen for messages is stored to
"~/Mail/.mew-refile-msgid-alist". `mew-lisp-max-length' controls
the amount of this information. The default value is 1000 messages. If
you want limits it to 2000 messages, put the following to "~/.emacs".

(setq mew-lisp-max-length 2000)

The function name to provide this feature is
`mew-refile-guess-by-message-id'.

6.4 Guess by private folders

In addition to the mechanism to select a mailing-list folder described
in See section 6.1 Guess by mailing-list folders, Mew provides a mechanism to choose a private
folder. Since private folders locate under +from, we can say that this
mechanism select a folder from the folders under +from. Let's see the
following example:

To: pooh@mew.org
From: piglet@mew.org

pooh received a message from piglet. If pooh uses this mechanism,
+from/piglet will be chosen according to From:. (Folders under +from can
be recurse. And you can select the entire address for a folder name
instead of the user part.)

The function to provide this feature is
`mew-refile-guess-by-from-folder'.

Next, let's consider a care where pooh replied to piglet. Since pooh
Cc:ed the message to himself, the message was also delivered to him.

To: piglet@mew.org
Cc: pooh@mew.org
From: pooh@mew.org

How do you feel if you are pooh? You may want to refile this to
+from/pooh. Also, you may want to move this to +from/piglet. So, it can
be customized.

If `mew-refile-guess-from-me-is-special' is `t' and if an
address in From: is yourself, `mew-refile-guess-by-from-folder'
select a folder under +from according to To: and/or Cc:.

6.5 Guess by From:

Mew also provides a mechanism to guess a folder by the place where a
message that has the same From: field is refiled.

Suppose that piglet has two addresses, piglet@beech.tree.uk and
p-p-p@mew.org. pooh wants to refile messages from piglet to
+from/piglet no matter what his From: is. This policy can, of course, be
implemented if pooh specifies rules explicitly as follows:

But such a work may bother you. So, first refile a message whose From:
is piglet@beech.tree.uk to +from/piglet. At this time, +from/piglet is
created. Next, refile a message whose From: is p-p-p@mew.org to
+from/piglet. Here Mews learns that p-p-p@mew.org was refiled to
+from/piglet. After this, when messages whose From: is p-p-p@mew.org
are refiled, +from/piglet is chosen.

For another example, you can refile messages from machinery to +adm/misc
without defining an explicit rule.

Information for relationship between From: and folder is stored to
"~/Mail/.mew-refile-from-alist". `mew-lisp-max-length' controls the
amount of this information as the same as See section 6.3 Guess by thread.

The function name to provide this feature is
`mew-refile-guess-by-from'.

If the value of `mew-refile-guess-from-me-is-special' is `t',
`mew-refile-guess-by-from' acts as
`mew-refile-guess-by-from-folder'(See section 6.4 Guess by private folders).

6.6 Guess by Newsgroups:

For those who read NetNews received by Email with Mew, Mew provides a
mechanism to guess a folder by Newsgroups:. It will be also useful when
Mew integrates NetNews in the future. The function name to provide this
feature is `mew-refile-guess-by-newsgroups'.

Mew executes every function defined in `mew-refile-guess-control'
in order. Each function may guess multiple candidates.

Let's see the following example of `mew-refile-guess-control'
action.

`mew-refile-guess-by-alist'

guessed +aaa, +bbb.

`mew-refile-guess-by-folder'

guessed +ccc, +ddd.

`mew-refile-guess-by-default'

guessed +eee.

If you want to provide all candidates, +aaa - +eee, set
`mew-refile-ctrl-multi' `t'. If you want to provide +aaa only,
set it `nil'.

If you want +aaa - +ddd but don't want left candidates, in other words,
you want +eee only when no candidate is guessed by functions executed
before, set `mew-refile-ctrl-multi' `t' and insert
`mew-refile-ctrl-throw' between `mew-refile-guess-by-folder'
and `mew-refile-guess-by-default'.

6.9 Auto refile

Those who receives many messages everyday is prone to store thousands of
messages in the +inbox folder. In such a case, they may want to speak
out like this, "Hey messages, get out of the +inbox folder to
somewhere". Mew provides a feature to satisfy such laziness. :)
`M-o' is the spell.

When you execute this function, it marks specific messages with
`o'. The specific messages mean messages which are not marked with
`o' nor `D' if `mew-refile-auto-refile-skip-any-mark' is
`nil'. If `mew-refile-auto-refile-skip-any-mark' is `t',
they mean non-marked messages. The default value of
`mew-refile-auto-refile-skip-any-mark' is `nil'. If executed
with `C-u', the targets mean messages marked with `*'
regardless the value of `mew-refile-auto-refile-skip-any-mark'.

Refile rule is the same described in the previous section. Please note
that what this function does is just mark messages with
`o'. Messages are not refiled until you will press `x'.

Mew's refile mechanism is so smart that it would be harmful for this
function. That is, most users would not understand where messages have
been refiled if Mew made most use of its guess mechanism. :) For this
reason, break is provided to limit usage of guess functions. Recall the
declaration up above.

You can find the `mew-refile-ctrl-auto-boundary' function in
`mew-refile-guess-control'. Only when auto refile is used, Mew
ignores guess functions below this function. If guess functions above
`mew-refile-ctrl-auto-boundary' didn't guess any folder for a
message, the message is not marked with `o'. Insert
`mew-refile-ctrl-auto-boundary' before you ruin.