On Wed, Feb 17, 1999 at 10:15:19AM -0600, David DeSimone <[EMAIL PROTECTED]> wrote:
> Brian Bray <[EMAIL PROTECTED]> wrote:
> >
> > just wondering about the easiest way to go about makeing deleted mail
> > transfer to a"trash" folder before for later retrival/deletion.
> 
> I have been using this patch to get a trash-folder effect; unfortunately
> I have lost the author's name.

Looks pretty good.  There are a few little nits, like including
globals.h.  And can a string variable ever be a NULL pointer?  I wasn't
sure, so I checked anyway in my patch.  At least using safe_strlen would
be good, I think.  Also, the patch doesn't check the exit status from
actually writing the messages to the mailbox, which is kind of bad.  It
does check whether the user is in the trash mailbox, which is good.
However, besides this, it has all the same problems as my patch.  I've
decided that maybe the problem of saving a copy of messages to the trash
when you don't actually delete them but just save them to another
folder, is OK.  I just looked at my MH docs, and this is how the rmmproc
functionality that I used to use there works.  However, the potential
saving of messages multiple times is annoying, still, and will not be
infrequent in really busy mailboxes.  However, I don't want to do this
whole operation with signals blocked.  But I gather that we're not
supposed to keep the mailbox locked with signals unblocked, right?
Aargh!  Can someone enlighten me on the issues involved with that?

-Daniel

> diff -u mutt-0.94.3i/Muttrc.in mutt-0.94.3i-trash/Muttrc.in
> --- mutt-0.94.3i/Muttrc.in    Fri Jun 26 06:31:19 1998
> +++ mutt-0.94.3i-trash/Muttrc.in      Sun Aug 23 22:02:42 1998
> @@ -144,6 +144,7 @@
>  # set timeout=600
>  # set tmpdir=""
>  # set to_chars="+TCF"
> +# set trash=""
>  # unset use_8bitmime
>  # set use_domain
>  # set use_from
> Common subdirectories: mutt-0.94.3i/doc and mutt-0.94.3i-trash/doc
> diff -u mutt-0.94.3i/globals.h mutt-0.94.3i-trash/globals.h
> --- mutt-0.94.3i/globals.h    Fri Jul 17 03:47:13 1998
> +++ mutt-0.94.3i-trash/globals.h      Sun Aug 23 22:02:42 1998
> @@ -77,6 +77,7 @@
>  WHERE char *Status;
>  WHERE char *Tempdir;
>  WHERE char *Tochars;
> +WHERE char *Trash;
>  WHERE char *Username;
>  WHERE char *Visual;
>  
> diff -u mutt-0.94.3i/init.h mutt-0.94.3i-trash/init.h
> --- mutt-0.94.3i/init.h       Mon Aug 10 11:28:31 1998
> +++ mutt-0.94.3i-trash/init.h Sun Aug 23 22:02:42 1998
> @@ -255,6 +255,7 @@
>    { "timeout",               DT_NUM,  R_NONE, UL &Timeout, 600 },
>    { "tmpdir",                DT_PATH, R_NONE, UL &Tempdir, 0 },
>    { "to_chars",              DT_STR,  R_BOTH, UL &Tochars, UL " +TCF" },
> +  { "trash",         DT_PATH, R_NONE, UL &Trash, UL "" },
>    { "use_8bitmime",  DT_BOOL, R_NONE, OPTUSE8BITMIME, 0 },
>    { "use_domain",    DT_BOOL, R_NONE, OPTUSEDOMAIN, 1 },
>    { "use_from",              DT_BOOL, R_NONE, OPTUSEFROM, 1 },
> diff -u mutt-0.94.3i/mx.c mutt-0.94.3i-trash/mx.c
> --- mutt-0.94.3i/mx.c Tue Jul 28 04:16:01 1998
> +++ mutt-0.94.3i-trash/mx.c   Sun Aug 23 22:02:42 1998
> @@ -23,7 +23,7 @@
>  #include "mailbox.h"
>  #include "copy.h"
>  #include "keymap.h"
> -
> +#include "globals.h"
>  
>  #ifdef _PGPPATH
>  #include "pgp.h"
> @@ -666,9 +666,41 @@
>    BUFFY *tmp = NULL;
>  #endif
>    int rc = -1;
> +  int i, nosave = 0;
> +  CONTEXT trash;
> +  struct stat st;
> +  char tmp[_POSIX_PATH_MAX+20];
>  
>    if (!ctx->quiet)
>      mutt_message ("Writing %s...", ctx->path);
> +    
> +  /* Only save messages to trash if there are deleted messages, 
> +     the Trash variable has been set,
> +     and the current folder isn't the trash. */
> +  if (ctx->deleted && strlen(Trash) && strncmp(ctx->path, Trash, _POSIX_PATH_MAX)) {
> +    errno = 0;
> +    stat(Trash, &st);
> +    if (errno == ENOENT && option (OPTCONFIRMCREATE)) {
> +      snprintf (tmp, sizeof (tmp), "Create trash mailbox, %s?", Trash);
> +      if (mutt_yesorno (tmp, 1) < 1) {
> +        if (mutt_yesorno("Purge deleted messages without saving?",1) < 1)
> +       return (-1);
> +     else
> +       nosave = 1;
> +      }
> +    }
> +    if (!nosave) {
> +      if (mx_open_mailbox (Trash, M_APPEND | M_QUIET, &trash) == NULL) {
> +        dprint (1, (debugfile, "sync_mailbox(): unable to open mailbox %s in 
>append-mode, aborting.\n", Trash));        
> +        return (-1);
> +      }
> +      for (i = 0; i < ctx->msgcount; i++)
> +        if (ctx->hdrs[i]->deleted)
> +          mutt_append_message(&trash, ctx, ctx->hdrs[i], 0, CH_UPDATE_LEN);
> +      mx_close_mailbox(&trash);
> +    }
> +  }
> +
>    switch (ctx->magic)
>    {
>      case M_MBOX:
> Common subdirectories: mutt-0.94.3i/rx and mutt-0.94.3i-trash/rx


-- 
Daniel Eisenbud
[EMAIL PROTECTED]

Reply via email to