Reputation: 7131
I am switching to GNU emacs for my python and bash scripting. I really enjoy this, but I don't like the X-window portion of emacs. As such, I always use emacs -nw <my_file>
to edit my files. However, when I associate my .py and .sh files with emacs, I end up opening emacs in X-window mode when I double-click on them from gnome-nautilus (Ubuntu 10.10).
What I would like to know is: What should I add to my .emacs file in order to use emacs without X-window when I double click on my files? Note: I do want emacs to open a terminal, possibly resize it according to my specifications (already have a .sh script for that), launch itself and open my file.
How should I accomplish that?
Cheers!
EDIT: Thanks for all the answers! I have to give the check to the most complete one, although of course it builds on the preceding ones.
Upvotes: 4
Views: 1719
Reputation: 370357
Building on Gareth's answer:
To open a file in an existing emacs session if one is running, but open a new one in a terminal if there isn't one, you can do the following:
(server-start)
to your .emacs
Create a script run_emacs
with the following contents:
#!/bin/bash
gnome-terminal -e "emacs -nw $@"
and make it executable.
Set your application to open python and bash files to be emacsclient -a /path/to/run_emacs %F
(if you place run_emacs
somewhere in your $PATH
, you can leave out the /path/to/
bit).
Upvotes: 3
Reputation: 65864
Johan has explained what to do if you want to launch a separate Emacs process for each file.
But normally, you would want to be running a single Emacs process and arrange that your files be opened in new buffers within the already-running Emacs process.
The way to do this is to start the Emacs server when you first start Emacs (for example, by running the server-start
command, or putting (server-start)
in your .emacs
) and arranging for Gnome to run the emacsclient
program.
Upvotes: 3
Reputation: 26526
If you use gnome you need to change the command line option for the emacs shortcut from
/usr/bin/emacs %F
to
gnome-terminal -e "/usr/bin/emacs -nw %F"
This can be done by right-clicking on the Application menu, select Edit Menus.
Upvotes: 1