Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use one instance of emacs as the default text editor? [Linux]

What I would like to achieve

  • one instance of emacs
  • if i open any text file from nautilus, it should open in the current emacs instance
  • if i close emacs, it shouldn't really close it, just hide it

What I have currently

  • I set emacs23 to start at startup
  • I have (start-server) in my init
  • I leave emacs open
  • I have emacsclient as the default texteditor

Issues I encountered while trying to achieve what I wanted

  • emacs gives the following error if i quit emacs and try to start it again

File error: Cannot bind server socket, address already in use

Things I tried

  • emacs wiki

  • stackoverflow

  • emacs fu

Update: I tried again with the stackoverflow link, and now most of it is working. However, something I would like to be able to do is to reload the init file, so that I can make changes to my init file without restarting the computer. Any ideas?

Also, if the server is running and I have emacs false-closed (see emacs fu link), how can i start it again without loading a file? eg what would the equivalent of running emacs23 be, as this doesn't work (see error written above)

like image 648
tobeannounced Avatar asked Dec 16 '10 08:12

tobeannounced


People also ask

How do I set the default text editor in emacs?

Making Emacs your default terminal editor If these files don't yet exist, opening an unknown file name with the emacs command will create a new file for you when you save. (The -nw Emacs flag opens the editor in non-GUI mode.) Save the file, exit the editor, and then restart your terminal.

What is the default text editor in Linux?

The Vi application is the default text editor on most Linux systems, so it's the primary interface you will use when you need to edit a configuration file. If you're used to a graphical text editor, such as Notepad++ or VS Code, Vi can be confusing at first.


1 Answers

  • remove (start-server) from .emacs
  • use emacsclient "$@" -a "" to start emacs whether it is running or not

If you save emacsclient "$@" -a "" as a script e.g. in editor file then editor -c creates a new frame, editor -t opens new frame in the terminal, and editor FILE visits FILE in an existing frame. It starts emacs server if it is not running.

like image 87
jfs Avatar answered Sep 19 '22 13:09

jfs