Go to the first, previous, next, last section, table of contents.


Expiration

Expiration means deletion of old messages which have outlasted a certain period of time.

wl-expire supports not only simple deletion, but also moving to specified archiving folders.

How to Use

Configure wl-expire-alist and press e in the folder mode, or M-e in the summary mode.

Configuring wl-expire-alist

An example configuration of wl-expire-alist is shown below. Everything in this wl-expire-alist makes a great difference in expiration, so be careful. I advise you to set wl-expire-use-log to t, especially in the initial stage.

(setq wl-expire-alist
      '(("^\\+trash$"   (date 14) remove)
                                  ;; delete
        ("^\\+tmp$"     (date 7) trash)
                                  ;; re-file to wl-trash-folder
        ("^\\+outbox$"  (number 300) "$outbox;lha")
                                  ;; re-file to the specific folder
        ("^\\+ml/tmp$"  nil)
                           ;; do not expire
        ("^\\+ml/wl$"   (number 500 510) wl-expire-archive-number1 t)
                           ;; archive by message number (retaining numbers)
        ("^\\+ml/.*"    (number 300 310) wl-expire-archive-number2 t)
                           ;; archive by a fixed number (retaining numbers)
        ("^\\+diary$"   (date 30) wl-expire-archive-date)
                           ;; archive by year and month (numbers discarded)
        ))

Items in the list has the format of:

(regexp-for-folders specification-of-messages-to-be-deleted destination)

The folder is examined if it matches regexp-for-folders from the beginning of the list. If you invoke expiration on the folder that does not match any of them, nothing will happen. And if either the second or the third element of the item is nil, expiration will not take place.

You can use any one of the following for specification-of-message-to-be-deleted:

(number n1 [n2])
deletes messages depending on the number of messages in the folder. n1 is the number of messages which should survive deletion, for example if its value is 500, the newest 500 messages survive and the rests are deleted. n2 is the number of messages in the folder on which expiration should take place, which defaults to n1 + 1. For example if its value is 510, folders with 510 or more messages are expired. If you configured automatic expiration, frequently used folders may expire every time it receive messages, and you may be annoyed with the long delay in reading mail. In that case, you can set a wide margin between n2 and n1, so that expiration would not take place until a certain number of messages accumulate. Messages with marks in wl-summary-expire-reserve-marks (marked with important/new/unread) are not deleted. If wl-expire-number-with-reserve-marks is non-nil, the folder will expire so as to have 500 messages including such ones. Otherwise, it will have 500 messages except such ones.
(date d1)
deletes messages depending on the dates. Messages dated d1 or more days ago are deleted, for example if its value is seven, messages seven days old or more are deleted. Note that the date is the one in the `Date:' field of the message, not when the message entered the folder. Messages with no or invalid `Date:' field does not expire; you might have to delete them by hand.

You can use any one of the following in the place of destination:

remove
deletes the messages instantly.
hide
hide the messages from summary (messages are not deleted).
trash
moves the messages to wl-trash-folder.
string(folder)
moves the messages to the folder specified with string. It would be useful for specifying an archiving folder, but because this does not move important messages, it might be better to use the standard functions described below.
function
invokes the specified function. To the function, three arguments are passed: a folder name, a list of messages to be deleted, and msgdb information of the summary. You can specify function-specific arguments after the name of the function. Note that the list contains messages with marks in wl-summary-expire-reserve-marks, be careful in writing your own function. These are four standard functions; three of them move messages to an archive folder in the specified way. This means old messages can be compressed and saved in a file, being deleted from the original folder. The last one divides messages to some MH folders.
wl-expire-archive-number1
re-files to archiving folders corresponding to the message numbers of the messages being deleted. For example, a message numbered 102 will be re-filed to `wl-00100.zip', 390 to `wl-00300.zip', and so on. If wl-expire-archive-files is 200, messages will be re-filed to `wl-00000.zip', `wl-00200.zip', `wl-00400.zip', .... The archiving folders to which messages are re-filed are determined by the name of the folder as follows (in this case, archiving folders are handled as if elmo-archive-treat-file were non-nil).
If the folder type is localdir:
`ArchiveDir/foldername-xxxxx.zip' For example, `+ml/wl' corresponds to `$ml/wl;zip' (`~/Mail/ml/wl-00100.zip').
The folder type is other than localdir:
`ArchiveDir/foldertype/foldername-xxxxx.zip' For example, `%#mh/ml/wl' corresponds to `$imap4/#mh/ml/wl;zip' (`~/Mail/imap4/#mh/ml/wl-00100.zip').
As you can see, in the case of localdir, the folder type is not included in the path name, but otherwise it is included. And you can control the prefix to the archiving folder name by wl-expire-archive-folder-prefix. Refer to wl-expire-archive-folder-prefix for details.
wl-expire-archive-number2
re-files every certain number of messages to archiving folders. This differs from `wl-expire-archive-number1' in that this re-files to the folder up to the specified number regardless of message numbers. The archiving folders to which messages are re-filed are determined in the same way as wl-expire-archive-number1.
wl-expire-archive-date
re-files messages depending on its date (year and month) to archive folders. For example, a message dated December 1998 is re-filed to $folder-199812;zip. The name of the archiving folders except the date part are determined in the same way as wl-expire-archive-number1. You can set the first argument to these three standard functions to non-nil in wl-expire-alist so as to retain message numbers in the folder. For example, it can be specified just after the name of the function:
("^\\+ml/wl$" (number 300 310) wl-expire-archive-number1 t)
If you omit the argument, consecutive numbers from 1 are assigned for each archiving folder.
wl-expire-localdir-date
divedes messages depending on its date (year and month) to MH folders e.g. to `+ml/wl/1999_11/', `+ml/wl/1999_12/'.

Treatment for Important or Unread Messages

If you specify any of remove, trash, a folder name, or a standard function, messages with marks in wl-summary-expire-reserve-marks (which are called reserved messages thereafter) are retained.

Per default, this variable include the important, new, and unread marks, so that messages with these marks are not removed. Note that you cannot include the temporary mark (i.e. temporary marks are removed anyway), and be sure to process temporary marks before you invoke expiration.

Auto Expiration

The following setup invokes expiration when you move into the summary mode. There will be no confirmation, so make sure you made no mistake in regexp and other settings before you set up this.

(add-hook 'wl-summary-prepared-pre-hook 'wl-summary-expire)

In the folder mode, you can invoke expiration per group as well as per folder. Therefore, if you specify `Desktop' group, all folders matching wl-expire-alist expire.

Tips

Treating archive folders.

To treat archive folders created by wl-expire-archive-number1 and so on, you must set non-nil value to elmo-archive-treat-file.

Confirming

If you are to use remove, try trash at first and see messages move to wl-trash-folder as expected, then replace it with remove. It would be dangerous to use remove from the beginning.

If you are to use wl-expire-archive-number1 and the like, try to make a folder of the archiver type (zip or lha) and see if you can append messages to it. Even if settings in wl-expire-alist and elmo-archive are correct, messages would not be saved anywhere and disappeared in case the archiver program fails.

After you make sure you can archive to the folder correctly, you can invoke expiration and utilize the log.

If you set wl-expire-use-log to t, `~/.elmo/expired-log' should contain the log, for example:

delete  +ml/wl  (593 594 595 596 597 598 599)
move    +ml/wl -> $ml/wl-00600;tgz;wl  (600 601 602)

The first column indicates the operation, i.e. `delete', `copy', or `move'. The next is the name of the folder that expired. In the case of `copy' and `move', the destination folder is recorded after `->'. The last is the list of message numbers that are actually deleted or moved (in the case of `copy' and `move', the number is the one in the source folder, rather than the destination folder).

Re-filing Reserved Messages

The three standard functions copy reserved messages to the archive folder, but do not delete them from the source folder. Because reserved messages and the like always remain, they are recorded in `~/.elmo/expired-alist' so that they are not copied over and over again. They are not recorded if copied by wl-summary-archive.

If you enabled logging, usually `move' is recorded for re-filing, but instead `copy' and `delete' are recorded separately if reserved messages are involved. This is because it actually copies messages including reserved, then deletes ones except reserved in that case.

Customizable Variables

wl-expire-alist
The initial setting is nil. This variable specifies folders and methods to expire. For details, refer to wl-expire-alist settings above.
wl-summary-expire-reserve-marks
The initial setting is the list below.
(list wl-summary-important-mark
      wl-summary-new-mark
      wl-summary-unread-mark
      wl-summary-unread-uncached-mark
      wl-summary-unread-cached-mark)
Messages with these marks are retained in the folder, even after expiration. Only permanent marks can be listed, not temporary marks. You can list marks one by one as in the default; you can use the following settings as well:
all
All messages with permanent marks are retained, i.e. wl-summary-read-uncached-mark is included in addition to the defaults.
none
All messages are handled as usual ones that are already read, no matter what marks they have; even important messages are deleted.
wl-expire-archive-files
The initial setting is 100. This variable specifies the number of messages to be retained in one archiving folder.
wl-expire-number-with-reserve-marks
The initial setting is nil. If non-nil, if expiring messages are specified by number, messages with wl-summary-expire-reserve-marks are also retained.
wl-expire-archive-get-folder-function
The initial setting is wl-expire-archive-get-folder. This variable specifies a function that returns the name of an archiving folder for standard functions in the place of destination. You can use the following three variables for simple modification of folder names; if you want more complex settings, define your own function in this variable. wl-expire-archive-get-folder can be customized by these variables:
wl-expire-archive-folder-name-fmt
The initial setting is `%s-%%05d;%s'. This is a format string for archiving folders used in wl-expire-archive-number1 and wl-expire-archive-number2. Note that you must specify the message number by `%%d', because it is parsed twice by format. If you modify this, adjust wl-expire-archive-folder-num-regexp as well.
wl-expire-archive-date-folder-name-fmt
The initial setting is `%s-%%04d%%02d;%s'. This is a format string for archiving folders used in wl-expire-archive-date. Note that you must specify the message number by `%%d', because it is parsed twice by format. There should be `%%d' twice, one for the year and the other for the month. If you modify this, adjust wl-expire-archive-date-folder-num-regexp as well.
wl-expire-archive-folder-type
The initial setting is zip. This variable specifies an archiver type of the archiving folders.
wl-expire-archive-folder-prefix
The initial setting is nil. This variable specifies the prefix (directory structure) to archiving folders. Exercise extreme caution in using this feature, as it has not been seriously tested. In the worst case, there is a fear of destructing archiving folders.
nil
There will be no prefix.
short
For example, `+ml/wl' will be prefixed by `wl', resulting in `$ml/wl-00000;zip;wl'.
t
For example, `+ml/wl' will be prefixed by prefix `ml/wl', resulting in `$ml/wl-00000;zip;ml/wl'.
wl-expire-archive-folder-num-regexp
The initial setting is `-\\([-0-9]+\\);'. This variable specifies the regular expression to be used for getting message numbers from multiple archiving folders specified by elmo-list-folders. Set it in accordance with wl-expire-archive-folder-name-fmt.
wl-expire-archive-date-folder-num-regexp
The initial setting is `-\\([-0-9]+\\);'. This is the regular expression to be used for getting message numbers from multiple archiving folders specified by elmo-list-folders. Set it in accordance with wl-expire-archive-date-folder-name-fmt.
wl-expire-delete-oldmsg-confirm
The initial setting is t. If non-nil, messages older than the one with the largest number will be deleted with confirmation. If nil, they are deleted without confirmation. This feature is valid only if non-nil is specified as a argument to the standard functions so as to retain numbers.
wl-expire-use-log
The initial setting is nil. If non-nil, expiration logs are recorded in `~/.elmo/expired-log'. They are appended but not truncated or rotated automatically; you might need to remove it manually.
wl-expire-add-seen-list
The initial setting is t. If non-nil, when messages are re-filed by expiration, read/unread information is passed to the destination folder. However if you do not read the destination folder from Wanderlust, `seen' under `~/.elmo/' grows larger and larger, so you might want to set this to nil if you are simply saving to some archiving folders. Even if its value is nil, messages in the archiving folders are simply treated as unread; it does not affect expiration itself.
wl-expire-folder-update-msgdb
The initial setting is t. If t, in the folder mode, expiration is carried out after updating summary information. If you specified a list of regular expressions of folder names, summary information is updated for matching folders only.


Go to the first, previous, next, last section, table of contents.