Disable swipe to delete in Mail.app on OS X 10.11

Posted: May 10th, 2016 | Author: | Filed under: code injection, macOS, Mail | 18 Comments »

OS X 10.11 ‘El Capitan’ added a new feature to Mail.app ‘Swipe to manage your inbox’:

Swipe to manage your inbox.
Now you can take care of your email with a swipe, just like on your iOS devices. Need to triage your inbox? Swipe right to mark an email as read or unread, or swipe left to delete. You’ll be focused on what’s important in no time.


Swipe To Delete

 

I find this new feature extremely annoying as I keep triggering it by accident. Sadly it seems that there is no preference (even secret preference) to disable this feature. But the good news is that Mail.app supports plugins.

To disable this feature, I created a simple Mail.app plugin. A precompiled version for Mail 9.3 (3124)
(OS X 10.11.4) can be downloaded here: DisableSwipeGesture.mailbundle.zip

 

You can download the source code here : Download ‘DisableSwipeGesture’ Source Code

 

Installation using the precompiled version for Mail 9.3 (3124) – OS X 10.11.4:

  • Download the precompiled version
  • Unzip
  • Copy the file into ~/Library/Mail/Bundles/
  • Relaunch Mail.app

 

Installation for other versions of Mail.app:

  • Download the DisableSwipeGesture source code
  • Open the project in Xcode
  • Build
  • Relaunch Mail.app

 

How does it work?

Mail.app uses a standard NSTableView to support the swipe to delete gesture. It implements the AppKit -tableView:rowActionsForRow:edge: delegate method to add the swipe to delete feature.

Before handling a swipe event, AppKit checks if swipe to delete is supported with the internal method -(BOOL)[NSTableView _allowSwipeToDeleteForEvent:]. The default implementation checks if the NSTableView is a view based tableview and if there is a delegate. The ‘DisableSwipeGesture’ Mail plugin overrides this internal method to always return NO i.e. to never allow swipe to delete. Note that this plugin only changes the behavior of Mail.app, it does not affect any other app. However the same mechanism could be used to disable the swipe to delete feature for any OS X app supporting plugins.

 

Mail.app plugin compatibility

Before loading any plugin, Mail.app checks if the plugin’s Info.plist contains the current Mail.app ‘PluginCompatibilityUUID’ value. If this is not the case, Mail.app will refuse to load the plugin and you will see an alert:


Incompatible Plugin

If you use this ‘DisableSwipeGesture’ plugin and you update Mail.app though an OS X update, you will need to update the PluginCompatibilityUUID value in the Info.plist of the ‘DisableSwipeGesture’ plugin. The simplest solution is to recompile the plugin using the steps provided in ‘Installation for other versions of Mail.app’. The Xcode project has a build phase that will extract the PluginCompatibilityUUID from /Application/Mail.app and copy it into the Info.plist.


18 Comments on “Disable swipe to delete in Mail.app on OS X 10.11”

  1. 1 Neal said at 8:38 pm on May 13th, 2016:

    Thank you!

  2. 2 Matthias said at 6:49 pm on May 19th, 2016:

    Awesome! Many thanks.

  3. 3 Gavin said at 7:17 am on May 25th, 2016:

    Hurray! Thanks!

  4. 4 Tomas said at 2:26 pm on May 30th, 2016:

    Thanks! Works on 10.11.4, can’t get it to work on 10.11.5 though, any ideas?

  5. 5 Tomas said at 11:36 am on May 31st, 2016:

    Never mind. I forgot to enable bundles on my 10.11.5 installation.

    For those who have the same problem: defaults write com.apple.mail EnableBundles -bool true

  6. 6 Mick said at 1:23 pm on July 26th, 2016:

    I just tried compiling this under xcode for Mail 10 on my Sierra beta and Mail subsequently rejected it as an incompatible plugin. Do you have a fix for this?

  7. 7 Timac said at 8:27 pm on July 26th, 2016:

    It seems that Mail.app uses a different key in the Info.plist on macOS 10.12. The new key uses the format “Supported%ld.%ldPluginCompatibilityUUIDs”.

    For macOS 10.12 beta 3, you would need to edit the Info.plist of the Mail plugin to add these lines:

    <key>Supported10.12PluginCompatibilityUUIDs</key>
    <array>
    	<string>36CCB8BB-2207-455E-89BC-B9D6E47ABB5B</string>
    </array>
    
  8. 8 Mick said at 3:57 am on July 27th, 2016:

    Thanks! Life is all good in the universe again :-).

  9. 9 OMG Yes said at 12:44 pm on August 12th, 2016:

    thank you so much

  10. 10 Mick said at 12:37 am on October 6th, 2016:

    And it’s dead again for the 10.1 betas. Any chance of waving your magic wand again?…

  11. 11 Mick said at 12:38 am on October 6th, 2016:

    Doh – I meant to say it’s dead for the 10.12.1 betas…

  12. 12 Timac said at 9:12 pm on October 24th, 2016:

    For macOS 10.12.1, you need to edit the Info.plist of the Mail plugin to add these lines:

    <key>Supported10.12PluginCompatibilityUUIDs</key>
    <array>
        <string>9054AFD9-2607-489E-8E63-8B09A749BC61</string>
    </array>
    

    To find the Mail.app supported key, you just need to run in the Terminal this command:
    defaults read /Applications/Mail.app/Contents/Info PluginCompatibilityUUID

  13. 13 LC said at 10:58 am on October 26th, 2016:

    works, but seems to have the unfortunate side effect of stopping any interaction with mail content. i can’t click on links in the mail body or ctrl-click at attachment to save it. i’ll have to uninstall and put up with the swipe annoyance. thanks for trying.

  14. 14 Timac said at 5:03 pm on October 26th, 2016:

    I don’t see the interaction issues with mail content. Click on links and control-click works as expected for me on 10.12.1.
    Make sure the issue is not caused by something else.

  15. 15 Mick said at 11:39 pm on November 17th, 2016:

    A belated thank you for showing how to get this working for 10.12.1 (and all subsequent OS versions)!

  16. 16 Martin said at 3:04 pm on January 6th, 2017:

    Cool. Awesome. Great job. Thanks alot.

    Had to enable bundles first but now everything is good again.

    defaults write com.apple.mail EnableBundles -bool true

  17. 17 J-F said at 12:04 am on February 3rd, 2017:

    Fantastic. Too bad I had to search so deeply in the web to find it. Every mac user should know that this marvellous plugin exists…

  18. 18 Al G. said at 11:17 pm on March 23rd, 2017:

    This is awesome, thanks!


Leave a Reply