Random ramblings about Mac, Python, TeX, programming, and more  |     |          |     |  


Mailspring and keyboard shortcuts

April 19, 2023  |  tools, macos

Mailspring is a free mail client for Mac, Linux and Windows (a paid Pro version is also available). Mailspring's user interface (UI) is open source (GPLv3). It is built on a plugin architecture and is designed to be easy to extend.

I have started using Mainspring on macOS recently, and since I find keyboard shortcuts important when using an email client efficiently, Mailscript's highly configurable keyboard shortcuts are a big plus. For work email, I have to use Microsoft Outlook, and I prefer if I can have the same keyboard shortcuts for both email clients. In Mainspring, when you go to the shortcuts section in settings, you can modify a set of keyboard shortcuts. But you can also choose «Edit custom shortcuts» to open the keymap.json file and edit it directly. This gives you the possibility to edit and add more keyboard shortcuts. A simple example of such a file, where the keyboard shortcut ⌘N is set to create a new message:

{
    "application:new-message": "mod+n"
}

When I started to edit and add keyboard shortcuts to this file, I wanted a complete list of possible functions (menus) that could be accessed with keyboard shortcuts. The best source I found was in the source code of Mailspring's UI. You can find all the menus of the email client in the app/menus/ folder of the source code, one file for each supported OS: darwin.js (macOS), linux.js (Linux), win32.js (Windows). For example, under the «Thread» menu on macOS you'll find this line:

{ label: localized('Move to Folder') + '...', command: 'core:change-folders' },

If I want to add a keyboard shortcut to move a message to a folder («Move to Folder…»), the line above from the source code identifies the function core:change-folders to be the function I am interested in. I can then update the keymap.json file to add ⇧⌘M as a keyboard shortcut for this function:

{
    "application:new-message": "mod+n",
    "core:change-folders": "shift+mod+m"
}
Last updated: December 29, 2023