Hot answers tagged

9 votes
Accepted

How to know if emacs is running as a daemon?

Simply use (daemonp) which will return t if emacs is running as a daemon.
user avatar
  • 2,594
9 votes
Accepted

bashrc script to automatically create emacs server session on startup?

The functionality is built into Emacs. Run emacsclient and pass it the -a (long form --alternate-editor) option with an empty argument, and it'll start Emacs (in daemon mode, i.e. initially without ...
user avatar
7 votes
Accepted

Run elisp from command line in running emacs

You can either wrap your two forms in a progn: emacsclient --no-wait --eval '(progn (message "hi") (setq abc 123))' Or you can send them separately: emacsclient --no-wait --eval '(message "hi")' '(...
user avatar
  • 31.1k
7 votes

Equivalent to --no-wait for emacs

Description The default behavior when invoking emacsclient is a little conservative. Check out this comment from emacsclient.c: /* Unless we are certain we don't want to occupy the tty, send our ...
user avatar
7 votes
Accepted

after-make-frame-functions does nothing for an otherwise working function

That FRAME argument to after-make-frame-functions that you're explicitly ignoring? Don't ignore it. (defun my-start-emacs (frame) "Switch client frames of an emacs daemon to the 'server' workgroup."...
user avatar
  • 43.9k
6 votes

Multiple Emacs instances each with their own server?

This answer has the general method, though the question was different than yours. You can use emacs --daemon=workspaceN combined with emacsclient -s workspaceN to have an emacs daemon on workspace N. ...
user avatar
6 votes

Emacs as server (daemon) struggles

Closing The Client Keep in mind that when you are running an emacs daemon, the frame in which you are actually editing is simply a client of the server. The file is not buffered in the client, it is ...
user avatar
  • 81
6 votes

How to test (programmatically) whether the current Emacs session (among several) is running the Emacs server?

You might check: (and (boundp 'server-process) (processp server-process) (server-running-p)) That should work provided that you've avoided starting a server in the other instances. ...
user avatar
  • 43.9k
5 votes

Emacs 24.5.1 on Windows: How to use server mode?

Add the following code to your init.el. (require 'server) (unless (server-running-p) (cond ((eq system-type 'windows-nt) (setq server-auth-dir "~\\.emacs.d\\server\\")) ((eq system-type '...
user avatar
  • 139
5 votes

How to get the server-name?

It appears daemonp will return the name of the server. I ended up with code that looks something like (cond ((string= "org" (daemonp)) (load-theme 'solarized-light) ) (t (load-theme 'solarized-...
user avatar
  • 357
5 votes
Accepted

How can I use Emacs in a SSH sever that I logged in through emacs terminal?

There is Tramp. You can edit a file on another machine using the syntax /ssh:user@machine:/path/to/file. If you take sudo instead of ssh, and empty user and machine, you can edit a local file as root. ...
user avatar
4 votes

How to get the server-name?

In a client instance the variable server-name is bound and contains the server name. (and (boundp 'server-name) server-name)
user avatar
  • 21.1k
4 votes
Accepted

server-edit vs kill-buffer to kill an emacsclient buffer

For me, using emacsclient with the '-n' switch prevents me from getting the "no client connection" warning. Invoking emacsclient file from the command line will open file in the current Emacs session....
user avatar
  • 196
4 votes

Is it possible to figure out which package/script takes most of the startup time?

Since you said you are already using use-package, you can turn on its own verbose option that reports how long each package takes to load. Use customize-option use-package-verbose or put this in your ...
user avatar
  • 19.4k
4 votes

Equivalent to --no-wait for emacs

I am unsure of how to do that strictly within Emacs, but luckily there are other ways to get what you describe. If you don't have something in your .emacs to start a server, you could always make a ...
user avatar
  • 2,046
4 votes

How to have C-g *not* cancel emacsclient eval commands?

After a lot of experimenting with writing wrappers around keyboard-quit (the default binding of C-g), I discovered that C-g has special behavior. If you bind C-S-g to keyboard-quit, it will not ...
user avatar
4 votes
Accepted

`server-start` hook?

You can wrap the relevant portions of you init file in a conditional on (daemonp), whose docstring reads: Return non-nil if the current emacs process is a daemon. If the daemon was given a name ...
user avatar
  • 31.1k
4 votes
Accepted

Changing the location of the emacs server socket

The directory where the socket is created is controlled by this variable: (defvar server-socket-dir (and (featurep 'make-network-process '(:family local)) (format "%s/emacs%d" (or (getenv "...
user avatar
  • 20.5k
4 votes
Accepted

How to control emacs externally?

I used the TCP approach suggested by @wvxvw in the comments. I'm starting a TCP server inside emacs, which, when receiving a package, will eval it as elisp code. I found a piece of code for the TCP ...
user avatar
  • 1,914
3 votes
Accepted

connect to remote emacs session via ssh

Since this is running on X, it might be possible to use a program like xdotool , xdo, or wmctrl All these programs allow you to list windows, select one, and simulate typing on them. Another ...
user avatar
  • 1,859
3 votes

How can I start a server in the background from a source code block without freezing emacs?

You can check out ob-async. It worked well for me. Someone said that you need to implement the feature for Emacs to do that. But ob-async does exactly what you want. It does run the process ...
user avatar
  • 183
3 votes
Accepted

Setting up emacsclient (OSX)

If you used Homebrew to set up Emacs, then you should have emacsclient symlinked under /usr/local/bin/emacsclient. Simply add (server-start) to your init file, and then emacsclient $FILE should open $...
user avatar
  • 3,403
3 votes

Why does using emacsclient from a remote host connect to the right socket, but I see nothing in my local Emacs?

This should work with a fairly recent emacsclient, as long as you pass in a prefix that lets the server emacs find remote files over tramp: --tramp=/ssh:remote: I can’t remember if the feature made ...
user avatar
3 votes

When `emacs` is started, use `emacsclient` instead if there is a server

Nowadays several megabytes are no problem for a client program. So maybe the problem of the size of Emacs is no longer that relevant. With Emacs 27 you can run stuff in ~/.emacs.d/early-init.el ...
user avatar
  • 30.5k
2 votes
Accepted

Emacs client starts in no windows mode

Use the -c option to force opening a new graphical frame.
user avatar
  • 21.1k
2 votes
Accepted

Helm command in `emacsclient -c` does nothing

If you had started the erroneous example from a terminal, you would have noticed output similiar to the following: $ emacsclient -c --eval '(helm-locate)' […] *ERROR*: Wrong number of arguments: (1 . ...
user avatar
  • 21.1k
2 votes

Emacs as server (daemon) struggles

I think that your 2nd attempt is correct. You should, however, use C-x C-c to quit Emacs and not close the frame created by emacsclient directly through the GUI. I use C-x C-c to quit Emacs and it ...
user avatar
2 votes
Accepted

Emacs server exit when losing connection to Xserver

I submitted a bug and got response that this is known bug of GTK since 2002. See etc/PROBLEMS: ** When Emacs is compiled with Gtk+, closing a display kills Emacs. As temporary solution - it is ...
user avatar
  • 3,130

Only top scored, non community-wiki answers of a minimum length are eligible