Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ForwardAsMime setting to control the default forwarding behavior #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 22 additions & 6 deletions MailFlow.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,28 +262,40 @@ def _decodeText(self, old):
class MessageViewController(Category('MessageViewController')):
@swizzle('MessageViewController', b'forward:')
def forward_(self, old, *args):
standard = lambda: self._messageViewer().forwardAsAttachment_(*args)
alternative = lambda: old(self, *args)
if not self._forwardAsMime:
standard, alternative = alternative, standard
event = NSApplication.sharedApplication().currentEvent()
if event and event.modifierFlags() & NSAlternateKeyMask:
return old(self, *args)
return self._messageViewer().forwardAsAttachment_(*args)
return alternative()
return standard()


class MessageViewer(Category('MessageViewer')):
@swizzle('MessageViewer', b'forwardMessage:')
def forwardMessage_(self, old, *args):
standard = lambda: self.forwardAsAttachment_(*args)
alternative = lambda: old(self, *args)
if not self._forwardAsMime:
standard, alternative = alternative, standard
event = NSApplication.sharedApplication().currentEvent()
if event and event.modifierFlags() & NSAlternateKeyMask:
return old(self, *args)
return self.forwardAsAttachment_(*args)
return alternative()
return standard()


class SingleMessageViewer(Category('SingleMessageViewer')):
@swizzle('SingleMessageViewer', b'forwardMessage:')
def forwardMessage_(self, old, *args):
standard = lambda: self._messageViewer().forwardAsAttachment_(*args)
alternative = lambda: old(self, *args)
if not self._forwardAsMime:
standard, alternative = alternative, standard
event = NSApplication.sharedApplication().currentEvent()
if event and event.modifierFlags() & NSAlternateKeyMask:
return old(self, *args)
return self.forwardAsAttachment_(*args)
return alternative()
return standard()


class MailFlow(Class('MVMailBundle')):
Expand All @@ -296,6 +308,10 @@ def initialize(self):
defaults = defaults.dictionaryForKey_('MailFlow') or {}
ComposeViewController._fixAttribution = defaults.get('FixAttribution', True)
MCMessageGenerator._flowWidth = int(defaults.get('FlowWidth', 76))
forwardAsMime = defaults.get('ForwardAsMime', True)
MessageViewController._forwardAsMime = forwardAsMime
MessageViewer._forwardAsMime = forwardAsMime
SingleMessageViewer._forwardAsMime = forwardAsMime

version = bundle.objectForInfoDictionaryKey_('CFBundleVersion')
NSLog('Loaded MailFlow %s' % version)
6 changes: 6 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,12 @@ set at the command line with the macOS defaults command:
default is 76. Set to 0 to disable format=flowed but still restrict
unnecessary use of quoted-printable.

defaults write com.apple.mail MailFlow -dict-add ForwardAsMime -bool false
defaults write com.apple.mail MailFlow -dict-add ForwardAsMime -bool true
- configure MailFlow to forward messages as MIME attachments by default
and inline if the Option key is held down. The default is on. Set to
false to swap the two behaviors, forwarding inline by default.


pbmbox
------
Expand Down