This short tutorial aimd to walk you step by step through defining Emacs as an external editor for PyCharm.
Basics of Emacs are out of scope of this tutorial.
Make sure that:
- You are working with PyCharm 2.7 or later.
- You have Emacs downloaded and properly installed on your computer.
Open Settings/Preferences dialog. To do that, you can, for example, choose File→Settings (on Windows and *nix) or PyCharm→Preferences (on Mac OS), or click button on the main toolbar.
Then, under the IDE settings, open the page External tools. On this page, you have to specify your Emacs installation as an external editor for the current file. This is how it's done...
Here, do the following:
- Type the tool name (Emacs) and optional description (Open Emacs)
- Specify the name of the group, under which Emacs will appear in the Tools menu. In this example, the group name is Editors. This step is optional - if you specify no group name, then Emacs will appear in the Tools menu as is.
- Unselect the check box Open console.
- Specify Emacs binary file location. You can either type it manually, or click the ellipsis button and find the desired binary in your file system.
- Since you want to open the current file in Emacs, pass the file path as a parameter to the program: in the Parameters field, type $FilePath$
- Finally, specify the working directory - in our example, this is $ProjectFileDir$
- Click OK.
Then apply changes and close the Settings/Preferences dialog.
When you now look at the Tools menu, you will see the new node Editors. Pointing to this node reveals the Emacs command:
Now, open a file in the PyCharm editor. Then, on the Tools menu, choose Editors→Emacs - and see the current file in Emacs also:
By the way, you can assign a keyboard shortcut to this action: click to open settings, open the Keymap page, in the list of actions find the node External Tools, expand the node Editors, right-click the nested node Emacs, and then choose Add keyboard shortcut command on the context menu:
Enter keyboard shortcut dialog box opens, where you have to specify which shortcut you would like this action to be associated with. Let’s, for example, use Ctrl+Alt+Shift+E:
No conflicts are reported, so click OK, and see the new shortcut appearing in the list of actions:
What has been done here?
- You've configured Emacs as an external editor.
- You've opened a current file in Emacs from within PyCharm.
- You've bound a keyboard shortcut to the new action.