unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] Have --format=mbox insert Status:
@ 2011-02-02 23:47 Peter John Hartman
  2011-02-05 23:08 ` Michal Sojka
  0 siblings, 1 reply; 5+ messages in thread
From: Peter John Hartman @ 2011-02-02 23:47 UTC (permalink / raw)
  To: notmuch

Hi folks,

This is not a complete patch, but should give you an idea.  (It works well
enough for me, but I think it could do more).

diff --git a/notmuch-show.c b/notmuch-show.c
index ef421ec..dff66de 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -272,6 +272,12 @@ format_message_mbox (const void *ctx,
 
     printf ("From %s %s", from, date_asctime);
 
+    if (strstr(_get_tags_as_string(ctx,message),"unread") != NULL) {
+      printf ("Status: O\n");
+    } else {
+      printf ("Status: RO\n");
+    }
+      
     while ((line_len = getline (&line, &line_size, file)) != -1 ) {
 	if (_is_from_line (line))
 	    putchar ('>');

It could, for instance, insert X-Status: AFTD flags, maybe, and it could be
a little more sensitive about O.  Maybe if tag is "new" it won't put the O
there, but I wasn't sure.  

Anyway, this is chiefly useful for me and others who use the mbox format. 
For instance, I combine notmuch with mutt as follows:

notmuch show --format=mbox $(notmuch search thread:xxx | cut -d' ' -f1) >
tmp.mbox && mutt -f tmp.mbox && rm -f tmp.mbox

Best,
Peter


-- 
sic dicit magister P
PhD Candidate
Collaborative Programme in Ancient and Medieval Philosophy
University of Toronto
http://individual.utoronto.ca/peterjh

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Have --format=mbox insert Status:
  2011-02-02 23:47 [PATCH] Have --format=mbox insert Status: Peter John Hartman
@ 2011-02-05 23:08 ` Michal Sojka
  2011-02-06 20:26   ` Peter John Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Sojka @ 2011-02-05 23:08 UTC (permalink / raw)
  To: Peter John Hartman, notmuch

On Wed, 02 Feb 2011, Peter John Hartman wrote:
> Hi folks,
> 
> This is not a complete patch, but should give you an idea.  (It works well
> enough for me, but I think it could do more).
> 
> diff --git a/notmuch-show.c b/notmuch-show.c
> index ef421ec..dff66de 100644
> --- a/notmuch-show.c
> +++ b/notmuch-show.c
> @@ -272,6 +272,12 @@ format_message_mbox (const void *ctx,
>  
>      printf ("From %s %s", from, date_asctime);
>  
> +    if (strstr(_get_tags_as_string(ctx,message),"unread") != NULL) {
> +      printf ("Status: O\n");
> +    } else {
> +      printf ("Status: RO\n");
> +    }
> +

Hi Peter,

would this output be compatible with all mbox consumers or only with
those who expect the Status: line? If the latter, we would probably want
a command line option to enable this.

> For instance, I combine notmuch with mutt as follows:
> 
> notmuch show --format=mbox $(notmuch search thread:xxx | cut -d' ' -f1) >
> tmp.mbox && mutt -f tmp.mbox && rm -f tmp.mbox

Interesting :)

-Michal

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Have --format=mbox insert Status:
  2011-02-05 23:08 ` Michal Sojka
@ 2011-02-06 20:26   ` Peter John Hartman
  2011-02-07  9:04     ` Michal Sojka
  0 siblings, 1 reply; 5+ messages in thread
From: Peter John Hartman @ 2011-02-06 20:26 UTC (permalink / raw)
  To: Michal Sojka; +Cc: notmuch

> Hi Peter,
> 
> would this output be compatible with all mbox consumers or only with
> those who expect the Status: line? If the latter, we would probably want
> a command line option to enable this.

Hi,

As far as I've been able to tell everyone respects RO in mbox, so I don't
see this as a problem.  In any case, having the Status: line there won't 
cause problems if an MUA doesn't recognize it.  That said, it would be nice
to think of a place to allow the user to easily "map" notmuch tags to
Status: or X-Status: rules, perhaps in the notmuch config file as follows:

[mbox]
synchronize_flags=true
xstatus_A=replied
xstatus_F=flagged
xstatus_T=draft
#xstatus_D=deleted
status_R=-unread
status_O=unread

Reference: http://wiki.dovecot.org/MailboxFormat/mbox:
  Status: R (\Seen) and O (non-\Recent) flags
  X-Status: A (\Answered), F (\Flagged), T (\Draft) and D (\Deleted) flags

(I know that alpine/pine and mutt recognize at least RO, and probably AFTD.)

Peter

-- 
sic dicit magister P
PhD Candidate
Collaborative Programme in Ancient and Medieval Philosophy
University of Toronto
http://individual.utoronto.ca/peterjh

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Have --format=mbox insert Status:
  2011-02-06 20:26   ` Peter John Hartman
@ 2011-02-07  9:04     ` Michal Sojka
  2011-02-07 14:22       ` Peter John Hartman
  0 siblings, 1 reply; 5+ messages in thread
From: Michal Sojka @ 2011-02-07  9:04 UTC (permalink / raw)
  To: Peter John Hartman; +Cc: notmuch

On Sun, 06 Feb 2011, Peter John Hartman wrote:
> > Hi Peter,
> > 
> > would this output be compatible with all mbox consumers or only with
> > those who expect the Status: line? If the latter, we would probably want
> > a command line option to enable this.
> 
> Hi,
> 
> As far as I've been able to tell everyone respects RO in mbox, so I don't
> see this as a problem.  In any case, having the Status: line there won't 
> cause problems if an MUA doesn't recognize it.  That said, it would be nice
> to think of a place to allow the user to easily "map" notmuch tags to
> Status: or X-Status: rules, perhaps in the notmuch config file as follows:
> 
> [mbox]
> synchronize_flags=true

I would call this differently - perhaps 'export_flags'. In maildir
section of config file synchronize_flags has the meaning of
bi-directional synchronization and this is only uni-directional.

> xstatus_A=replied
> xstatus_F=flagged
> xstatus_T=draft
> #xstatus_D=deleted
> status_R=-unread
> status_O=unread

Is it necessary for this to be configurable? Given the list bellow, it
seems it is already defined by the "standard", so users would rarely
want different mapping.


> Reference: http://wiki.dovecot.org/MailboxFormat/mbox:
>   Status: R (\Seen) and O (non-\Recent) flags
>   X-Status: A (\Answered), F (\Flagged), T (\Draft) and D (\Deleted) flags
> 
> (I know that alpine/pine and mutt recognize at least RO, and probably AFTD.)

-Michal

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] Have --format=mbox insert Status:
  2011-02-07  9:04     ` Michal Sojka
@ 2011-02-07 14:22       ` Peter John Hartman
  0 siblings, 0 replies; 5+ messages in thread
From: Peter John Hartman @ 2011-02-07 14:22 UTC (permalink / raw)
  To: Michal Sojka; +Cc: notmuch

On Mon, Feb 07, 2011 at 10:04:41AM +0100, Michal Sojka wrote:
> > [mbox]
> > synchronize_flags=true
> 
> I would call this differently - perhaps 'export_flags'. In maildir
> section of config file synchronize_flags has the meaning of
> bi-directional synchronization and this is only uni-directional.

I agree.

> 
> > xstatus_A=replied
> > xstatus_F=flagged
> > xstatus_T=draft
> > #xstatus_D=deleted
> > status_R=-unread
> > status_O=unread
> 
> Is it necessary for this to be configurable? Given the list bellow, it
> seems it is already defined by the "standard", so users would rarely
> want different mapping.

I agree.  In fact, I would think we don't need to add anything to the
notmuch config file at all.  I can't think of a use case where we'd want
show --format=mbox to *not* also replicate/export the Status/X-Status tags.
I personally don't use X-Status: but I don't have a problem with my patch
being patched to include them.  It won't cause any problems.

Peter


-- 
sic dicit magister P
PhD Candidate
Collaborative Programme in Ancient and Medieval Philosophy
University of Toronto
http://individual.utoronto.ca/peterjh

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-02-07 14:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-02 23:47 [PATCH] Have --format=mbox insert Status: Peter John Hartman
2011-02-05 23:08 ` Michal Sojka
2011-02-06 20:26   ` Peter John Hartman
2011-02-07  9:04     ` Michal Sojka
2011-02-07 14:22       ` Peter John Hartman

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).