]> git.neil.brown.name Git - edlib.git/commitdiff
doc-email: send a notification when a 'transformed' pane is made visible.
authorNeilBrown <neil@brown.name>
Fri, 26 May 2023 09:07:14 +0000 (19:07 +1000)
committerNeilBrown <neil@brown.name>
Fri, 26 May 2023 22:18:43 +0000 (08:18 +1000)
We don't really want to process attachments until asked.  So allow the
transform tool to be notified when it is time.

Signed-off-by: NeilBrown <neil@brown.name>
doc-email.c

index 2914556210ee89a21dc12417c2f1b6ecad6e83ce..49d2cca3ad4bd3b46825fbc0e0e51b4c095aa0ea 100644 (file)
@@ -590,22 +590,22 @@ static bool handle_text(struct pane *p safe, char *type, char *xfer, char *disp,
        else
                asprintf(&ctype, "%1.*s", majlen, major);
        if (ctype && strcasecmp(ctype, "text/html") == 0) {
-               transformed = call_ret(pane, "html-to-text-w3m", h);
+               transformed = call_ret(pane, "html-to-text-w3m", h, 1);
                if (!transformed)
-                       transformed = call_ret(pane, "html-to-text", h);
+                       transformed = call_ret(pane, "html-to-text", h, 1);
        }
        if (ctype && strcasecmp(ctype, "text/calendar") == 0)
-               transformed = call_ret(pane, "ical-to-text", h);
+               transformed = call_ret(pane, "ical-to-text", h, 1);
        if (ctype && strcasecmp(ctype, "application/pdf") == 0)
-               transformed = call_ret(pane, "pdf-to-text", h);
+               transformed = call_ret(pane, "pdf-to-text", h, 1);
        if (ctype && strcasecmp(ctype, "application/octet-stream") == 0 &&
            fname && strcasestr(fname, ".pdf") != NULL)
-               transformed = call_ret(pane, "pdf-to-text", h);
+               transformed = call_ret(pane, "pdf-to-text", h, 1);
        if (major && strncasecmp(major, "application", majlen) == 0 &&
            fname && (strcasestr(fname, ".docx") != NULL ||
                      strcasestr(fname, ".doc") != NULL ||
                      strcasestr(fname, ".odt") != NULL))
-               transformed = call_ret(pane, "doc-to-text", h, 0, NULL, fname);
+               transformed = call_ret(pane, "doc-to-text", h, 1, NULL, fname);
 
        if (ctype && strncasecmp(ctype, "image/", 6) == 0) {
                struct mark *m;
@@ -1206,6 +1206,17 @@ DEF_CMD(email_view_set_attr)
                mark_free(m1);
                mark_free(m2);
 
+               if (w && strcmp(w, "transformed") == 0) {
+                       /* If the transformation was delayed, tell it
+                        * to start now.
+                        */
+                       struct pane *part =
+                               call_ret(pane, "doc:multipart:get-part",
+                                        ci->home->parent, p+1);
+                       if (part)
+                               call("doc:notify:convert-now", part);
+               }
+
                return 1;
        }
        return Efallthrough;