Skip to content

Instantly share code, notes, and snippets.

@fnurl
Last active January 13, 2017 21:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fnurl/bc5b48e14cd3da11173aa63992936cea to your computer and use it in GitHub Desktop.
Save fnurl/bc5b48e14cd3da11173aa63992936cea to your computer and use it in GitHub Desktop.
A hook for alot that adds format="flowed" to the Content-type header
# This hook needs some changes to the alot code
#
# Currently, only commands initiated from the command line have hooks.
# However, in order to add this hook, we need all commands to have hooks,
# also those created by other commands.
#
# When replying to a message in a thread, the thread.reply command
# is triggered, but it in turn triggers compose which in turn triggers
# edit. These two last commands do not have any hooks attached to them.
#
# The following branch and pull request fixes this:
# - https://github.com/fnurl/alot/tree/hook-always
# - https://github.com/pazz/alot/pull/967
def pre_envelope_edit(ui=None, dbm=None, cmd=None):
envelope = cmd.envelope
if envelope is not None:
content_type = envelope.get_all("Content-type")
if content_type == []:
envelope['Content-type'] = u'text/plain; charset="utf-8"; format="flowed"'
elif 'text/plain' in content_type:
if 'format="flowed"' not in content_type:
envelope.add('Content type', 'format="flowed"')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment