9front - general discussion about 9front
 help / color / mirror / Atom feed
* [9front] [PATCH] nedmail: only display most useful headers
@ 2024-02-06 14:41 phil9
  2024-02-06 17:14 ` umbraticus
  2024-02-06 18:07 ` unobe
  0 siblings, 2 replies; 11+ messages in thread
From: phil9 @ 2024-02-06 14:41 UTC (permalink / raw)
  To: 9front

Hi,

Below patch limits the headers displayed by nedmail to the most "useful"
ones:Date, From, To, CC (is set) and Subject.
This helps with some mailing lists or mail providers adding loads of noisy headers.
This only applies to the 'p' command and all headers are still visible
when using the 'P' (display raw) command so nothing is lost.

cheers
--phil


diff 081b58a69e5efc2bbf49ee31099372527edb3fa7 uncommitted
--- a/sys/src/cmd/upas/ned/nedmail.c
+++ b/sys/src/cmd/upas/ned/nedmail.c
@@ -1664,6 +1664,18 @@
 	return c;
 }
 
+void
+printheaders(Message *m)
+{
+	Bprint(&out, "Date: %s\n", m->date);
+	Bprint(&out, "From: %s\n", m->from);
+	Bprint(&out, "To: %s\n", m->to);
+	if(strlen(m->cc)>0)
+		Bprint(&out, "CC: %s\n", m->cc);
+	Bprint(&out, "Subject: %s\n", m->subject);
+	Bprint(&out, "\n");
+}
+
 Message*
 pcmd0(Cmd *c, Message *m, int mayplumb, char *tfmt)
 {
@@ -1684,10 +1696,9 @@
 	}
 	if(m->parent == &top){
 		seen(m);
-		printpart(m, "unixheader", nil);
+		/* only print headers for top part */
+		printheaders(m);
 	}
-	if(printpart(m, "header", nil) > 0)
-		Bprint(&out, "\n");
 	cp = findctype(m);
 	if(cp->flag & Display){
 		if(strcmp(m->type, "text/html") == 0)


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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-06 14:41 [9front] [PATCH] nedmail: only display most useful headers phil9
@ 2024-02-06 17:14 ` umbraticus
  2024-02-06 17:17   ` ori
  2024-02-06 17:38   ` phil9
  2024-02-06 18:07 ` unobe
  1 sibling, 2 replies; 11+ messages in thread
From: umbraticus @ 2024-02-06 17:14 UTC (permalink / raw)
  To: 9front

isn't this what /mail/lib/ignore is for?

I believe Ori toyed with this when he was writing Nail
and suggested an inverse so you could specify only what
you wanted; not sure whether that made it in.

umbraticus

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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-06 17:14 ` umbraticus
@ 2024-02-06 17:17   ` ori
  2024-02-06 17:38   ` phil9
  1 sibling, 0 replies; 11+ messages in thread
From: ori @ 2024-02-06 17:17 UTC (permalink / raw)
  To: 9front

Quoth umbraticus@prosimetrum.com:
> isn't this what /mail/lib/ignore is for?
> 
> I believe Ori toyed with this when he was writing Nail
> and suggested an inverse so you could specify only what
> you wanted; not sure whether that made it in.
> 
> umbraticus

I don't believe it did.


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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-06 17:14 ` umbraticus
  2024-02-06 17:17   ` ori
@ 2024-02-06 17:38   ` phil9
  2024-02-07  4:23     ` umbraticus
  1 sibling, 1 reply; 11+ messages in thread
From: phil9 @ 2024-02-06 17:38 UTC (permalink / raw)
  To: 9front

On Wed, Feb 07, 2024 at 06:14:43AM +1300, umbraticus@prosimetrum.com wrote:
> isn't this what /mail/lib/ignore is for?
> 
not exactly, headers listed in /mail/lib/ignore are never exposed by
upas/fs whereas this patch is only cosmetic, you can still see all headers
if you so desire.


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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-06 14:41 [9front] [PATCH] nedmail: only display most useful headers phil9
  2024-02-06 17:14 ` umbraticus
@ 2024-02-06 18:07 ` unobe
  1 sibling, 0 replies; 11+ messages in thread
From: unobe @ 2024-02-06 18:07 UTC (permalink / raw)
  To: 9front

I like it, thanks phil!  One other that I would add (like CC, only if
set) is inreplyto.  But maybe that's not most useful to you and
others.

Quoth phil9 <telephil9@gmail.com>:
> Hi,
> 
> Below patch limits the headers displayed by nedmail to the most "useful"
> ones:Date, From, To, CC (is set) and Subject.
> This helps with some mailing lists or mail providers adding loads of noisy headers.
> This only applies to the 'p' command and all headers are still visible
> when using the 'P' (display raw) command so nothing is lost.
> 
> cheers
> --phil
> 
> 
> diff 081b58a69e5efc2bbf49ee31099372527edb3fa7 uncommitted
> --- a/sys/src/cmd/upas/ned/nedmail.c
> +++ b/sys/src/cmd/upas/ned/nedmail.c
> @@ -1664,6 +1664,18 @@
>  	return c;
>  }
>  
> +void
> +printheaders(Message *m)
> +{
> +	Bprint(&out, "Date: %s\n", m->date);
> +	Bprint(&out, "From: %s\n", m->from);
> +	Bprint(&out, "To: %s\n", m->to);
> +	if(strlen(m->cc)>0)
> +		Bprint(&out, "CC: %s\n", m->cc);
> +	Bprint(&out, "Subject: %s\n", m->subject);
> +	Bprint(&out, "\n");
> +}
> +
>  Message*
>  pcmd0(Cmd *c, Message *m, int mayplumb, char *tfmt)
>  {
> @@ -1684,10 +1696,9 @@
>  	}
>  	if(m->parent == &top){
>  		seen(m);
> -		printpart(m, "unixheader", nil);
> +		/* only print headers for top part */
> +		printheaders(m);
>  	}
> -	if(printpart(m, "header", nil) > 0)
> -		Bprint(&out, "\n");
>  	cp = findctype(m);
>  	if(cp->flag & Display){
>  		if(strcmp(m->type, "text/html") == 0)
> 


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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-06 17:38   ` phil9
@ 2024-02-07  4:23     ` umbraticus
  2024-02-07  6:06       ` phil9
  0 siblings, 1 reply; 11+ messages in thread
From: umbraticus @ 2024-02-07  4:23 UTC (permalink / raw)
  To: 9front

> not exactly, headers listed in /mail/lib/ignore are never exposed by
> upas/fs whereas this patch is only cosmetic, you can still see all headers
> if you so desire.

I suppose there is some difference but the existing mechanism already
provides the beheviour you describe (p prints non-ignored headers and
P prints the raw mail with all headers) and if you want to root around
in /mail/fs/mbox/* then rawheader is always there too. *shrug*

umbraticus

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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-07  4:23     ` umbraticus
@ 2024-02-07  6:06       ` phil9
  2024-02-07  6:54         ` chris
  0 siblings, 1 reply; 11+ messages in thread
From: phil9 @ 2024-02-07  6:06 UTC (permalink / raw)
  To: 9front

On Wed, Feb 07, 2024 at 05:23:20PM +1300, umbraticus@prosimetrum.com wrote:
> > not exactly, headers listed in /mail/lib/ignore are never exposed by
> > upas/fs whereas this patch is only cosmetic, you can still see all headers
> > if you so desire.
> 
> I suppose there is some difference but the existing mechanism already
> provides the beheviour you describe (p prints non-ignored headers and
> P prints the raw mail with all headers) and if you want to root around
> in /mail/fs/mbox/* then rawheader is always there too. *shrug*
> 
> umbraticus

Nope, actually you're absolutely right using /mail/lib/ignore achieves
exactly what I was trying to do, my bad.

thanks
--phil


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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-07  6:06       ` phil9
@ 2024-02-07  6:54         ` chris
  2024-02-07  9:03           ` umbraticus
  0 siblings, 1 reply; 11+ messages in thread
From: chris @ 2024-02-07  6:54 UTC (permalink / raw)
  To: 9front

> I suppose there is some difference but the existing mechanism already
> provides the beheviour you describe (p prints non-ignored headers and
> P prints the raw mail with all headers) and if you want to root around
> in /mail/fs/mbox/* then rawheader is always there too. *shrug*
> 
> umbraticus

Neat, I didn't know about /mail/lib/ignore . Is that documented somewhere?

I didn't find anything in mail(1), nedmail(1) etc.

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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-07  6:54         ` chris
@ 2024-02-07  9:03           ` umbraticus
  2024-02-07 12:25             ` chris
  0 siblings, 1 reply; 11+ messages in thread
From: umbraticus @ 2024-02-07  9:03 UTC (permalink / raw)
  To: 9front

> Neat, I didn't know about /mail/lib/ignore . Is that documented somewhere?

Not sure, can't remember how I found out about it.

nedmail(1) also doesn't cover a bunch of commands
(including frequently used ones like P and ") which
are nevertheless there and printed by the help command.

a real hero would attach a diff to this mail

umbraticus

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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-07  9:03           ` umbraticus
@ 2024-02-07 12:25             ` chris
  2024-02-07 17:37               ` umbraticus
  0 siblings, 1 reply; 11+ messages in thread
From: chris @ 2024-02-07 12:25 UTC (permalink / raw)
  To: 9front

> a real hero would attach a diff to this mail

Heroes use nedmail(1)!

The ignore part is now located in upasfs(4) since it is implemented there and not in nedmail.
I added all nedmail commands I am aware of, although I don't use some.

diff 7155de5d97ffa0d7cc91e6cce8307db64490da3b uncommitted
--- a//sys/man/1/nedmail
+++ b//sys/man/1/nedmail
@@ -164,16 +164,25 @@
 .I sendername
 is the account name of the sender.
 .TP
+.B H
+Print the MIME structure of the message.
+.TP
 .B h
 Print the disposition, size in characters, reception time, sender,
 and subject of the message.
 .TP
-.B H
-Print the MIME structure of the message.
-.TP
 .B help
 Print a summary of the commands.
 .TP
+.B i
+Incorporate new mail.
+.TP
+.BI k " [flags]
+Mark mail. See upasfs(4) for available flags.
+.TP
+.BI K " [flags]
+Unmark mail.
+.TP
 .BI m " person ...
 Forward the message as a mime attachment to the named
 .IR persons .
@@ -184,10 +193,29 @@
 but allow the user to type in text to be included
 with the forwarded message.
 .TP
+.BI mb " mbox
+Switch mailbox to mbox located at /mail/box/username/mbox .
+.TP
 .B p
 Print message.
 An interrupt stops the printing.
 .TP
+.B P
+Print the raw message including hidden headers as filtered by /mail/lib/ignore (see upasfs(4)).
+.TP
+.B \&"
+Print a quoted version of msg.
+.TP
+.B \&"\&"
+Format and quote message.
+.TP
+.B q
+Put undeleted mail back in the mailbox and stop.
+.TP
+EOT (control-D)
+Same as 
+.BR q .
+.TP
 .BI r " args
 Reply to the sender of the message.
 .I Marshal
@@ -228,7 +256,7 @@
 doesn't start with a `/', it is interpreted relative to the directory in which the mailbox resides.
 If
 .I mfile
-is a directory then the destination is a file in that directry.
+is a directory then the destination is a file in that directory.
 If the MIME header specifies a file name, that one is used.
 Otherwise, one is generated using
 .IR mktemp (2)
@@ -235,22 +263,15 @@
 and the string
 .BR att.XXXXXXXXXXX .
 .TP
-.B q
-Put undeleted mail back in the mailbox and stop.
+.B t
+Text formatter.
 .TP
-EOT (control-D)
-Same as 
-.BR q .
-.TP
-.BI w " file
-Same as
-.B s
-with the mail header line(s) stripped.  This can be used to
-save binary mail bodies.
-.TP
 .B u
 Remove mark for deletion.
 .TP
+.BI w " file
+Store message contents as file.
+.TP
 .B x
 Exit, without changing the mailbox file.
 .TP
@@ -326,6 +347,9 @@
 .TP
 .B /mail/box/*/L.mbox
 mutual exclusion lock for altering mbox
+.TP
+.B /mail/lib/ignore
+header filter regarding 'p' c
 .SH SOURCE
 .B /sys/src/cmd/upas/ned
 .SH "SEE ALSO"
--- a//sys/man/4/upasfs
+++ b//sys/man/4/upasfs
@@ -459,6 +459,12 @@
 .TP
 .B /mail/box/*/L.mbox
 mutual exclusion lock for altering mbox (mbox format only)
+.TP
+.B /mail/lib/ignore
+Headers to ignore on regular display.
+.TP
+.B /mail/lib/blocked
+Addresses to refuse to accept messages from.
 .SH SOURCE
 .TP
 .B /sys/src/cmd/upas/fs


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

* Re: [9front] [PATCH] nedmail: only display most useful headers
  2024-02-07 12:25             ` chris
@ 2024-02-07 17:37               ` umbraticus
  0 siblings, 0 replies; 11+ messages in thread
From: umbraticus @ 2024-02-07 17:37 UTC (permalink / raw)
  To: 9front

nice! thanks

umbraticus

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

end of thread, other threads:[~2024-02-07 17:39 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-06 14:41 [9front] [PATCH] nedmail: only display most useful headers phil9
2024-02-06 17:14 ` umbraticus
2024-02-06 17:17   ` ori
2024-02-06 17:38   ` phil9
2024-02-07  4:23     ` umbraticus
2024-02-07  6:06       ` phil9
2024-02-07  6:54         ` chris
2024-02-07  9:03           ` umbraticus
2024-02-07 12:25             ` chris
2024-02-07 17:37               ` umbraticus
2024-02-06 18:07 ` unobe

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 NNTP newsgroup(s).