[patch] width parameter in mailcap
Hi, All,
I am new here.
I made a small patch to rfc1524.c so the mailcap viewer which accept a
width parameter can expand %w into the term size. This can be used in
example:
text/html; lynx -width=%w -dump %s; copiousoutput;
which utilizes the large term window.
I realize this is out of the specification of RFC1524, what is the
general approach on these type of enhancements?
Not tried yet, but I am thinking of further enhancements so %w-10 can
expand into COLS-10 (the term size minus 10) so the pager can utilize
the large term size but still leave a margin of 10.
BTW, What is the status of mutt's support of RFC 2646 --
format=flowed, other than the text_flowed option? It seems there are
some code in the src dealing with flowed message, but I can't find it
in any documentation. I am currently using a perl script as a mailcap
viewer which can re-adjust the message to user's term size. However, I
am troubled by how to pass the "format=flowed" option to the viewer.
Thanks for attention.
--
Hui Zhou
diff -ur mutt-1.4.2.1-orig/rfc1524.c mutt-1.4.2.1/rfc1524.c
--- mutt-1.4.2.1-orig/rfc1524.c 2001-05-15 03:23:49.000000000 -0400
+++ mutt-1.4.2.1/rfc1524.c 2004-04-27 15:33:32.559093688 -0400
@@ -28,6 +28,7 @@
#include "mutt.h"
#include "rfc1524.h"
+#include "mutt_curses.h"
#include <string.h>
#include <stdlib.h>
@@ -51,6 +52,20 @@
* In addition, this function returns a 0 if the command works on a file,
* and 1 if the command works on a pipe.
*/
+char* myitoa(unsigned int i,char* buf, int bufsize)
+{
+ unsigned lsd;
+ char* psz=buf+bufsize-1;
+ *psz=0;
+ do{
+ lsd=i%10;
+ i/=10;
+ psz--;
+ *psz='0'+lsd;
+ }while(i!=0);
+ return psz;
+}
+
int rfc1524_expand_command (BODY *a, char *filename, char *_type,
char *command, int clen)
{
@@ -58,6 +73,7 @@
int needspipe = TRUE;
char buf[LONG_STRING];
char type[LONG_STRING];
+ char width[17];
strfcpy (type, _type, sizeof (type));
@@ -97,6 +113,10 @@
y += mutt_quote_filename (buf + y, sizeof (buf) - y, filename);
needspipe = FALSE;
}
+ else if (command[x] == 'w')
+ {
+ y += mutt_quote_filename (buf + y, sizeof (buf) - y,
myitoa(COLS,width,17));
+ }
else if (command[x] == 't')
{
y += mutt_quote_filename (buf + y, sizeof (buf) - y, type);