Assuming an Emacs server is running, I want emacsclient <file>
to either create a new frame (like -c
) when there is no existing frame or reuse an existing frame when there is one. In other words, I want the -c
only when there is no existing frame. Is that possible?
相关问题
- Symbol's function definition is void: declare-
- How can I set the SVN password with Emacs 23.1 bui
- Emacs shell: save commit message
- emacs bind key to the insertion of another
- Emacs - set mark on edit location
相关文章
- ess-rdired: I get this error “no ESS process is as
- Emacs/xterm color annoyance on Linux
- Pipe less to Emacs
- Capturing the output of “diff” with org-babel
- emacs terminal mode: how to copy and paste efficie
- How to permanently enable the hs-minor-mode in ema
- Pipe emacs shell output to a new buffer
- Following a link into a git-repo without lengthy d
I solved my problem with a set of shell scripts.
my_emacs
You may need to change emacs24-x to something that points to your X11 emacs.
my_emacsclient
Add both files to you PATH via ~/bin or the like.
In my .emacs I also added the followings lines
Also change some environment variables and optionally add an alias
When you run
e
in your shell it should create or resuse an existing GUI frame. Also, runninge <filename>
opens that file in a frame; you can also pass other flags like-n
toe
.For the same behaviour in other applications (say your file manager), you should also change the Emacs .desktop file (for me that's
/usr/share/applications/emacs24.desktop
) to runmy_emacs
.It might also be a good idea to change
emacs
tomy_emacsclient
via the alternatives system in Debian-based (?) distributions.You might want to try `emacsclient --display "$DISPLAY" " to force creation of a GUI frame if there isn't one yet.
Here's my solution:
In your emacs startup file (e.g.: ~/.emacs/init.el), ensure that you have the following lines:
Then, add the following to your ~/.bashrc file:
To establish a baseline, make sure you exit all emacs instances and kill the emacs daemon if you currently have it running.
Then, from the command line, 'source' the ~/.bashrc file:
Finally, use 'e' to edit a file:
emacsclient <file>
does what you want.If you just want to open a frame without specifying a file, then you need to use
-c
.