Getting EmacsKeys working with QtCreator 3.1.2
Contents
Today, Qt 5.3.1 was released along with Qt Creator 3.1.2. Unfortunately, nsf’s EmacsKeys plugin, merged into the Qt trunk a few months ago, was not a part of this release (it should be included in Qt Creator 3.2).
Because the Emacs keybindings are hardwired into my fingers, and I’m using QtCreator for a project at the moment, I spent some time figuring out how to get the plugin built for Qt Creator 3.1.2. This post explains how you too can build it, but, if you’re on Ubuntu 14.04 with Qt 5.3.1 x64, you can just download my binaries and the keymap file (see under requirements).
I’ve tried to setup most of the common Emacs keybindings documented in nsf’s plugin, plus a few more, and I’ve gotten rid of the conflicts. (Thanks nsf for putting me on the right path with that!)
Requirements
You need to have Qt 5.3.1 installed. I used the open source x64 .run
files made available by the qt-project.
<p>
For both of the following approaches, download and unpack <a href="http://vxlabs.com/downloads/qtcreator-emacskeys-x64-20140625.tar.gz">the qtcreator-emacskeys archive</a> I’ve prepared especially for you.
</p>
The Easy Way: Install Binaries
-
Copy the archive
nsf
directory toQt/Tools/QtCreator/lib/qtcreator/plugins
. -
Copy the archive
emacskeys.kms
toQt/Tools/QtCreator/share/qtcreator/schemes
. - Start QtCreator.
-
In
Help | About | Plugins
activateEmacsKeys
underUtilities
. - Restart QtCreator.
-
Under
Tools | Options | Environment | Keyboard
click onImport
and then selectemacskeys.nsf
.
<p>
You can scroll down to the Emacs Keys section and check that my choices work for you.
</p>
The Hard Way: Build ’em Yourself
Get the Qt Creator source code by typing:
<pre class="brush: plain; title: ; notranslate" title="">
git clone –recursive https://git.gitorious.org/qt-creator/qt-creator.git
<p>
Copy the <code>src/plugins/emacskeys</code> directory somewhere else, out of the whole <code>qt-creator</code> tree, because you’re going to revert to the 3.1.2 release version:
</p>
<pre class="brush: plain; title: ; notranslate" title="">
cd qt-creator git checkout tags/v3.1.2
<p>
Copy the <code>emacskeys.pro</code> from my archive into the <code>emacskeys</code> directory that you copied out. Edit <code>QTCREATOR_SOURCES</code> to point to te v3.1.2 qt-creator checkout that you prepared above, and <code>IDE_BUILD_TREE</code> to point to your installed QtCreator directory.
</p>
<p>
In QtCreator, open the .pro file that you’ve just edited, and build the project. If all goes according to plan, this will put the resultant .so file into the correct plugins directory in a subdirectory called <code>nsf</code>.
</p>
<p>
Now follow the rest of the steps from <b>the easy way</b> above.
</p>
Limitations
I experienced the problem that Alt-W
would deselect any existing mark at the press of Alt
, so nothing was copied. To get around this, I’ve mapped copy to Esc-W
.