diff options
author | Thomas Roessler <roessler@does-not-exist.org> | 2000-06-15 21:15:51 +0000 |
---|---|---|
committer | Thomas Roessler <roessler@does-not-exist.org> | 2000-06-15 21:15:51 +0000 |
commit | e93492141eb952d9a09ed8a8d6738cd09372a162 (patch) | |
tree | c233851713b82bfda41ac4bab931e2a0e1230580 | |
parent | 3414418461702a37c247d642e732c62aa4ddbb4c (diff) |
patch-1.2.bbell.display_filter.2.
-rw-r--r-- | commands.c | 45 | ||||
-rw-r--r-- | globals.h | 1 | ||||
-rw-r--r-- | init.h | 7 |
3 files changed, 41 insertions, 12 deletions
@@ -25,6 +25,9 @@ #include "copy.h" #include "mx.h" #include "pager.h" +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #ifdef USE_IMAP #include "imap.h" @@ -61,7 +64,10 @@ int mutt_display_message (HEADER *cur) char tempfile[_POSIX_PATH_MAX], buf[LONG_STRING]; int rc = 0, builtin = 0; int cmflags = M_CM_DECODE | M_CM_DISPLAY | M_CM_CHARCONV; - FILE *fpout; + FILE *fpout = NULL; + FILE *fpfilterout = NULL; + pid_t filterpid; + int res; snprintf (buf, sizeof (buf), "%s/%s", TYPE (cur->content), cur->content->subtype); @@ -107,7 +113,23 @@ int mutt_display_message (HEADER *cur) return (0); } - mutt_message_hook (cur, M_DISPLAYHOOK); + mutt_message_hook (cur, M_DISPLAYHOOK); + + if (DisplayFilter && *DisplayFilter) + { + fpfilterout = fpout; + fpout = NULL; + endwin (); + filterpid = mutt_create_filter_fd (DisplayFilter, &fpout, NULL, NULL, + -1, fileno(fpfilterout), -1); + if (filterpid < 0) + { + mutt_error (_("Cannot create display filter")); + fclose (fpfilterout); + unlink (tempfile); + return 0; + } + } if (!Pager || mutt_strcmp (Pager, "builtin") == 0) builtin = 1; @@ -118,20 +140,19 @@ int mutt_display_message (HEADER *cur) fputs ("\n\n", fpout); } - if (mutt_copy_message (fpout, Context, cur, cmflags, - (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM) == -1) + res = mutt_copy_message (fpout, Context, cur, cmflags, + (option (OPTWEED) ? (CH_WEED | CH_REORDER) : 0) | CH_DECODE | CH_FROM); + if ((fclose (fpout) != 0 && errno != EPIPE) || res == -1) { - fclose (fpout); - unlink (tempfile); + mutt_error (_("Could not copy message")); + if (fpfilterout != NULL) + mutt_wait_filter (filterpid); + mutt_unlink (tempfile); return 0; } - if (fclose (fpout) != 0 && errno != EPIPE) - { - mutt_perror ("fclose"); - mutt_unlink (tempfile); - return (0); - } + if (fpfilterout != NULL && mutt_wait_filter (filterpid) != 0) + mutt_any_key_to_continue (NULL); #ifdef HAVE_PGP /* update PGP information for this message */ @@ -37,6 +37,7 @@ WHERE char *Charset; WHERE char *ComposeFormat; WHERE char *DefaultHook; WHERE char *DateFmt; +WHERE char *DisplayFilter; WHERE char *DsnNotify; WHERE char *DsnReturn; WHERE char *Editor; @@ -367,6 +367,13 @@ struct option_t MuttVars[] = { ** for deletion. This applies when you either explicitly delete a message, ** or when you save it to another folder. */ + { "display_filter", DT_PATH, R_PAGER, UL &DisplayFilter, "" }, + /* + ** .pp + ** When set, specifies a command used to filter messages. When a message + ** is viewed it is passed as standard input to $$display_filter, and the + ** filtered message is read from the standard output. + */ #if defined(DL_STANDALONE) && defined(USE_DOTLOCK) { "dotlock_program", DT_PATH, R_NONE, UL &MuttDotlock, UL BINDIR "/mutt_dotlock" }, /* |