wangp / bower

A curses terminal client for the Notmuch email system
Other
119 stars 11 forks source link

Formatting non-text parts other than HTML using external commands #33

Closed aperezdc closed 6 years ago

aperezdc commented 6 years ago

Currently it is already possible to use the html_dump option in the configuration file to convert HTML parts to plain text:

[command]
  html_dump = lynx ...

It would be super nice if it would be possible to specify how invoke filters to handle other MIME types, for example:

[filters]
  # Replaces the html_dump setting above.
  text/html = lynx ...

  # Prints .ics files to stdout as plain text.
  text/calendar = vcal -start -end -summary /dev/stdin

  # PDF files, too!
  application/pdf = pdftotext - -
wangp commented 6 years ago

This is implemented on the 'filter' branch. I've barely tested it but it seems to work. I'll merge it to master if nothing turns up in the next week or so.

aperezdc commented 6 years ago

Some moments ago I built Bower from the filter branch and seems to work like a charm. I'll keep using this build for the next days as well to give it some more testing.

Thanks a ton for looking into this — I would have liked to contribute a patch but Mercury is completely alien to me :innocent:

wangp commented 6 years ago

Actually, there's a potential deadlock if you're filtering large "text" parts as the pipe to the external process can fill up. So don't do that yet. (text/html is okay.)

aperezdc commented 6 years ago

So far I have tried only wit small parts under ~20 KiB, if I remember correctly. Let me know if I can help trying out things somehow.

wangp commented 6 years ago

I've pushed a fixed version to master. Enjoy.

aperezdc commented 6 years ago

JFTR, in case someone else arrives here: I have discovered that khal —which I was using already— can also print .ics files. Now I am using the following instead:

[filters]
  text/calendar = khal printics

I love this feature, thanks again @wangp for implementing it!