How to change default text editor from Geany to emacs-nox on Crunchbang (Debian) Jessie (Testing)

Hello,

You do not use geany. You use emacs, in the terminal. But you also use crunchbang. You are also strange, and even though you don’t often use the file manager that ships with crunchbang, Thunar, when you do, it always opens stuff in Geany, and you want it to open in emacs. In addition, when you want to edit the config files for Openbox or Conky, they all open in Geany. In addition, when you type Super+e, you get geany, instead of emacs. We shall fix all of these things.

Prerequisites:

Be sure to have emacs-nox installed. This will only install the CLI version of emacs. The windowed version and all it’s dependencies won’t be downloaded. If you have the normal version of emacs installed instead of emacs-nox, whenever you see ’emacs’ you will have to use ’emacs -nw’. I will alert you the first few times.

sudo apt-get install emacs24-nox

Reassigning keyboard shortcut for Super+e from geany to emacs

1. Open up terminal and type:

emacs ~/.config/openbox/rc.xml

2. Search for the evil geany:

C+s geany Enter

3. Replace that with the following and save:

terminator -x emacs

C+x C+s

4. Reload the config files for openbox’s rc.xml:

M+! killall -USR2 openbox Enter

5. Go wild pressing Super+e spawning terminator’s running emacs.

Updating the Crunchbang Menu Entries to open .config files in emacs-nox instead of geany

1.  If you’re still in emacs do:

C+x C+f ~/.config/openbox/menu.xml Enter

2. Now that we’ve got the menu config file open, we need to find and replace all instances of

<item label=”Edit menu.xml”>
<action name=”Execute”>
<command>
geany ~/blahblahblah
</command>
</action>

With:

<command>
terminator –command=”emacs ~/.config/openbox/menu.xml”
</command>

So whenever you see menu.xml wanting to edit a config file, and it’s doing the geany crap, replace it with the preceding. Make sure to get the file paths correct for each of the entries.

3. Now that all the config files will be opening with emacs, we need to replace the Text Editor entry in the default menu.

Go to the top of the file:

A+<

Search for the offending string:

C+s Text Editor Return

Replace:

<command>geany</command>

With:

<command>terminator –command=”emacs”</command>

5. Finally, let’s update the Accessories -> Geany Text Editor with something more appropriate.

5.1 Go back to the top of the file.
5.2 Search for “Geany Text Editor”
5.3 Replace that with “Emacs Text Editor”
5.4 Immediately below that, replace:

<command>
geany
</command>

With:

<command>
terminator –command=”emacs”
</command>

5.5 Reconfigure the openbox .config files again.
5.6 Rejoice

Make thunar open emacs instead of geany

1. If you’re still in emacs, open (create) the file at the following location:

~/.local/share/applications/emacs.desktop

2. Put the following in it and save it:

[Desktop Entry]
Name=Emacs-nox
Comment=Edit text files
Exec=terminator -x emacs %F
Terminal=false
Type=Application
Icon=Emacs24
Categories=;
StartupNotify=true
MimeType=text/plain;

3. Open ~/.local/share/applications/defaults.list

4. Replace every offending instance of geany.desktop with emacs.desktop and save the file.

5. Logout and log back in for good measure.

6. Text files should default to emacs. If they don’t automatically, right click the file, and click Open With Other Application. Search for emacs-nox in your seemingly randomly assorted list of Other Applications. Click it, and make sure Use as default for this kind of file is checked, and Open the file.

7. Rejoice.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.