简体   繁体   中英

GNU Emacs customization - no window

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.

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 .

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:

  1. Add (server-start) to your .emacs
  2. Create a script run_emacs with the following contents:

     #!/bin/bash gnome-terminal -e "emacs -nw $@" 

    and make it executable.

  3. 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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM