#449 ✓bluesky
Mike K

Feature request: use external text editor

Reported by Mike K | September 23rd, 2013 @ 08:08 PM


Comments and changes to this ticket

  • benny

    benny September 24th, 2013 @ 08:45 AM

    • State changed from “new” to “bluesky”
    • Tag changed from editing, formatting to rich text, editing, formatting, html

    Thanks for your detailed feedback on this issue. I am sure you are not alone with respect to having issues with the Markdown-only approach to rich text. My general thoughts about rich text in emails are still pretty well covered in my 2011 blog post. The main difference since then is that inline images are now supported.

    Ideally, what you want (I believe) is an HTML editor in MailMate. It sounds like an easy solution to support an external HTML editor, but it's probably easier than it sounds. The work needed to be done is not really the editor itself (it's a standard OS X component). It is quite likely that it would be easier for me to simply add an HTML editor as an alternative within MailMate. For new messages it might not even be that hard while for replies/forwards (of HTML messages) it could be very tricky (this also often does not work well in other email clients). That said, my own motivation for an HTML editor would be as a fallback for replies/forwards which are not always gracefully handled by MailMate, because of the need to convert to plain text (Markdown). In many cases, it could be handled better by an HTML editor.

    In theory (and quite often in practice), HTML for emails is a broken feature in any email client. In practice, unfortunately, it works well enough to be widely supported. I try to be pragmatic, but it is very difficult to enthusiastically implement something that will never work well in general.

    For you, it might be sufficient with a WYSIWYG editor for Markdown (although colored text would not be supported), but that does not solve the problems related to replying/forwarding HTML messages. The advantage of a WYSIWYG editor for Markdown is that it would still allow me to generate a proper plain text body part alternative.

    Comments are welcome from anyone. I'm open for suggestions and/or the pressure of public demand :-) I'm not religiously against offering an alternative to plain text, but I'm also not currently motivated to put it very high on the list (pushing other items further down). To put it in perspective, we are in the territory of someone buying a $10K license key to change my mind ;-)

    I'll put this ticket in the “bluesky” state which basically means to not expect this to change soon.

  • Mike K

    Mike K September 28th, 2013 @ 01:11 AM

    • no changes were found...
  • Januz

    Januz January 30th, 2014 @ 08:24 AM


    I would also like to use an external editor, but not to use a WYSIWYG editor, but to be able to use my standard text editor (i.e., VIM in my case) for writing plain text mails. Using VIM would allow me to write/edit mails much faster...

    Is that something that would be easier to implement?


  • O'Shaughnessy Evans

    O'Shaughnessy Evans January 31st, 2014 @ 04:58 AM

    Hi, Benny. I just discovered MailMate and I've really enjoyed its performance and features as I've been exploring it. I find that I keep looking for an email app that would let me pop over to MacVim to write messages. I haven't found any Mac app that supports such a feature. If there's a way to write a plugin to do it, I'd take a shot at it. If not, is it a feature you'd consider adding?


  • benny

    benny January 31st, 2014 @ 09:46 AM

    @Januz/Evans: It's something I would consider and it's certainly a much simpler request than HTML support. In theory, all it would require is that MailMate can be told to save the message text to a temporary file, open an external editor, and then watch the file for changes (triggered when it's saved by the external editor). It could even happen automatically when tab'ing into the text field of the composer. But no time frame on this though :-)

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 1st, 2014 @ 06:18 AM

    Nice to hear that it sounds feasible, though. And nobody else on the market has one that supports it, at least as far as I've been able to find. nudge nudge :-)

  • Mike

    Mike February 1st, 2014 @ 06:49 PM

    Messenger Pro on RISC OS has this feature. ;-)

  • benny

    benny February 1st, 2014 @ 09:38 PM

    Hold down ⌥ when clicking “Check Now” in the Software Update preferences pane (r3984). Implemented today. Very little testing done. Here is what I wrote in the release notes:

    First shot at supporting external editors. This is how it works:

    • A bundle command can be created with the special key/value pair saveForEditing = 1;.
    • saveForEditing makes MailMate save the current content of the text view of the composer to a file before running the command.
    • The command is given the filepath and it can then launch the editor.
    • MailMate watches the file and updates the text view in the composer when the file changes.

    Some additional notes:

    • An example bundle is included which works for TextMate.
    • The file extension .eml.txt is used to allow the editor to identify it as an email text file (to allow specific settings for this without affecting all .txt files).
    • The example bundle has two commands (⌃⇧O and ⌃⌥⇧O). The difference is that only one of them activates MailMate after closing the document in TextMate. I've included both since this trick might not work for all text editors.

    Experimentally, the following preference can be used to make MailMate auto-open the text editor when using the keyboard to enter the text view in the composer (either by replying or by tab'ing into the text view):

    defaults write com.freron.MailMate MmBundleCommandLaunchedOnTab -string "0CE35D01-7B5D-4112-B379-E7BFC10AC55A"

    The string is the UUID of the bundle command.

    I should add that to make your own bundle for your preferred text editor then you should do something like this:

    1. Copy the TextMate bundle:

      mkdir -p ~/Library/Application\ Support/MailMate/Bundles
      cp /Applications/MailMate.app/Contents/SharedSupport/Bundles/TextMate.mmBundle ~/Library/Application\ Support/MailMate/Bundles/
    2. Rename anything in the bundle to match the name of your text editor.

    3. Replace all UUIDs with new values (use uuidgen in the Terminal).

    4. Look into what is needed to make your text editor open the given file.

    5. Test.

    6. If it works, share. If it doesn't work, ask.

    This might also be a way to allow HTML editing at some point, but I still consider that a bluesky feature and I'll keep the ticket status.

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 7th, 2014 @ 02:25 AM

    Hi, Benny. Does output from the bundle commands go somewhere? I'm unsure how to debug my scripts.


  • benny

    benny February 7th, 2014 @ 08:17 PM

    @Evans: The output goes back to MailMate. In some cases MailMate uses the output to perform certain actions (also undocumented). For example, moving/tagging messages or creating drafts.

    You can debug by redirecting output to a file and then maybe watch that file using tail -f.

    You can also get additional debug output like this:

    defaults write com.freron.MailMate MmDebugCommands -bool YES

    Then launch MailMate from the Terminal:

  • Steve Mayer

    Steve Mayer February 8th, 2014 @ 01:38 AM

    Just a bit of info here. For those MacVim users, give VimAnywhere [https://github.com/cknadler/vim-anywhere] a try. It works well for me here (especially with the vim-markdown plugin).

  • benny

    benny February 8th, 2014 @ 10:58 AM

    A dedicated bundle for MailMate would probably work better (I haven't looked into vim-anywhere). I'm sure someone is going to make that for MacVim eventually ;-)

  • Michael A Osborne

    Michael A Osborne February 9th, 2014 @ 10:39 PM

    I'd hugely appreciate support for Sublime Text if anyone thought this were achievable

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 08:19 PM

    I'm working on a MacVim bundle, but I'm getting stuck somewhere.

    I've used the Sublime Text and TextMate bundles as templates and created one called MacVim.mmBundle. When I run MailMate directly from Terminal, I see it being invoked:

    % ~/Applications/MailMate.app/Contents/MacOS/MailMate
    2014-02-13 12:13:43.998 MailMate[68331:507] performBundleItemWithUUIDString: 08BF1E23-F39E-48E1-98C7-08D909A8CAA7

    That's the unique UUID that I generated with uuidgen. That's all the output I see, though. When I run the Sublime Text or TextMate bundles, it looks like MailMate is dumping the environment variables before executing the edit script. The same isn't happening with mine. Perms on that script are the same, it's called exactly the same. I even tried copying the Sublime Text.mmBundle dir to ~/Library/Application SUpport/MailMate/Bundles/MacVim.mmBundle, changing the title and uuid in info.plist and the uuid in Commands/Edit.mmCommand, but I still don't get the same output. It seems that at a bare minimum, that should work.

    Got any tips? I feel like I'm missing some magic somewhere.

  • benny

    benny February 13th, 2014 @ 08:23 PM

    Did you change the UUID in the info.plist file as well?

    Do you see the bundle/command in the Command menu?

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 08:26 PM

    Here's my edit script, BTW. It works fine from the command line when I define MM_EDIT_FILEPATH directly.

    #exec >/tmp/mm-vim.log 2>&1
    #set -x
    hash mvim 2>/dev/null && VISUAL=mvim || VISUAL=Vim
    osascript -e 'tell app "MailMate" to activate'
  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 08:28 PM

    Yep. Changed the UUID in info.plist and the Commands file.


        contactEmailRot13 = "funht+znvyzngr@jhzchf.bet";
        contactName = "O'Shaughnessy Evans";
        description = "MacVim integration";
        name = "MacVim";
        uuid = "08BF1E23-F39E-48E1-98C7-08D909A8CAA7";


        name          = "Edit";
        saveForEditing = 1;
        command       = '#!/bin/sh\n"${MM_BUNDLE_SUPPORT}/bin/edit"\n';
        keyEquivalent = "^~O";
        uuid          = "08BF1E23-F39E-48E1-98C7-08D909A8CAA7";
  • benny

    benny February 13th, 2014 @ 08:30 PM

    Ah, the UUIDs should not be the same. Each item in a bundle must have its own UUID.

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 08:32 PM

    So to further explain my testing, I'm opening up a new message and then invoking Command->MacVim->Edit or Command->TextMate->Edit. The stdout/stderr from MailMate, as viewed in the terminal, is very different between my bundle and the ones you've included in the app.

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 08:34 PM

    Ah, the UUIDs should not be the same. Each item in a bundle must have its own UUID.


  • benny

    benny February 13th, 2014 @ 08:36 PM

    I hope that means it works now :-)

    Any particular reason you call sh instead of `bash? It's a bit paranoid, but I think it's safer to know which shell type is going to execute the script (not important in this one-line script, but if someone else bases their bundle on your bundle)...

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 08:53 PM

    Yep, that fixed it. Thanks!

    sh vs bash: just old habit. Back when sh was a bare POSIX shell and bash wasn't likely to be installed (and included a lot more stuff) I would always call sh. A bare install of Unix that isn't OS X or Linux won't include bash. It has more cruft and would therefore be more heavyweight to invoke, but looking at the size of the binaries (and this page at stackexchange), it seems they're essentially the same in our context.

    So for consistency I should probably change it to bash. I think we're pretty well guaranteed that either one is going to look like a POSIX sh for these scripts anyway.

    I'm curious about something else. Some of the external commands have an ellipsis in their title ("Calendar -> Create Event...", "Evernote -> Add..."). Is there something implied by leaving it out of the "Edit" command titles?

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 08:55 PM

    (So thinking about sh vs bash and being paranoid, that's probably the essence of what's behind my use of sh. I assume it's going to be more strictly a POSIX shell while I never know what may grow or change in bash. sh seems to me like the safer choice.)

  • benny

    benny February 13th, 2014 @ 09:09 PM

    Now you made me read up on it ;-) Although sh can point to any implementation of a shell then it must be a POSIX shell which means it's fine if you write your script POSIX style. On OS X sh appears to simply be bash --posix. So, it's probably a little bit safer with sh, but I'm used to bash :-)

    I assume you'll share your bundle. Maybe even allow me to include it with MailMate (until a better distribution method is available) :-)

  • benny

    benny February 13th, 2014 @ 09:12 PM

    I forgot the ellipsis question. Ellipsis is used when the user is expected to provide more information in a window/panel. This is open for interpretation in this case. Apparently I opted for not adding ellipsis. Apple writes about it here.

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 09:30 PM

    Ah, thanks! Good reference about the ellipsis.

    So I'm curious about the keyboard shortcuts. Is there a good convention to use here?

    I'll upload a bundle (is zip preferred, or .tar.gz?) once I've run out of niggling little questions to ask :-)

  • benny

    benny February 13th, 2014 @ 09:37 PM

    I would like all of these text editor bundles to use the same shortcut. I'm thinking ⌃⇧O. Currently, there is no easy way to disable bundles, but when there is then usually a user would only enable one of these bundles. Until then you can use whatever shortcut you like (but I'll change it or ask you to change it when bundles can be disabled). Just note that it can be tricky to avoid overlapping standard text editor shortcuts :-)

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 09:51 PM

    Well, this is just fun. Thanks for all the help -- you've been amazingly responsive.

    Here's a bundle for MacVim. Until you want to change it, it uses shift-control-M to jump to MacVim. I wanted something with "V", but those all seem to be taken.

    I'm curious how the "command" string is invoked. I tried calling $MM_BUNDLE_SUPPORT/bin/edit directly, thinking it was probably an exec call or something like it, but that didn't work. edit already invokes #!/bin/sh, so it seems superfluous to invoke it twice, but I didn't find a away around it.

    Thanks again. I've really enjoyed this. Let me know if you see anything that needs to be changed, or feel free to refactor things yourself. Of course, you're welcome to include it with the other bundles, too.

  • O'Shaughnessy Evans

    O'Shaughnessy Evans February 13th, 2014 @ 09:53 PM

    (Note: bundle attached in previous comment but the system has marked it as spam.)

  • Olivier Martin

    Olivier Martin February 16th, 2014 @ 10:46 AM

    Thanks for the VIM bundle !

  • benny

    benny February 17th, 2014 @ 12:20 PM

    @Evans: I've included the bundle in the latest test release. Thanks for the contribution! I noticed your script for enabling MacVim as the automatically launched editor, but I'm still a bit unsure how it can/should be generalized to work for all editor bundles. Maybe as a command in a meta-bundle which looks through all bundles for candidates and then shows a popup for selecting an editor :-)

  • Michael A Osborne

    Michael A Osborne March 30th, 2014 @ 03:10 PM

    Many thanks to all those who contributed; the Sublime Text support has proved extraordinarily useful to me.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Mac OS X email client.

Shared Ticket Bins

People watching this ticket


Referenced by