Skip to main content
Share Your Experience: Take the 2024 Developer Survey
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 ...
Gilles 'SO- stop being evil''s user avatar
8 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."...
phils's user avatar
  • 51.5k
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")' '(...
Dan's user avatar
  • 33.1k
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 ...
mwood's user avatar
  • 101
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. ...
phils's user avatar
  • 51.5k
5 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 ...
Jesse's user avatar
  • 1,994
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. ...
Michael Albinus's user avatar
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 '...
husky's user avatar
  • 149
5 votes
Accepted

Cannot start Emacs daemon server after forced reboot

To prevent multiple daemon sessions with the same name running, Emacs daemon server uses a lock file. Normally when the daemon stops (say by running kill-emacs), it deletes this file as part of ...
holocronweaver's 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 ...
Dan's user avatar
  • 33.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 "...
NickD's user avatar
  • 30.5k
4 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 ...
Tobias's user avatar
  • 33.2k
4 votes
Accepted

Open file at startup from init file

You can use server-after-make-frame-hook: (add-hook 'server-after-make-frame-hook (lambda () (find-file "~/my-file.org")))
d125q's user avatar
  • 1,443
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 ...
icarus's user avatar
  • 1,924
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 ...
Peder Klingenberg's user avatar
3 votes

emacs in --deamon mode dies when X display socket closes. How to prevent this?

The answer to the question is to use the Lucid version of emacs. With Ubuntu, the package is called emacs25-lucid. From comments in the code and it also pops out on stderr if you can managed to get ...
pedz's user avatar
  • 375
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 ...
Jaehyun's 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 $...
Daniel's user avatar
  • 3,653
3 votes
Accepted

How to debug emacsclient?

Sadly that could be a lot of things. I think you will need to run the emacs inside of gdb Run gdb --args emacs -nw, then start the server in that emacs. a. Alternatively, start the server normally, ...
db48x's user avatar
  • 18.3k
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 ...
Libre Arch's user avatar
2 votes
Accepted

Separate Environments for each emacsclient

You'll want to look at the environment frame parameter, which the server.el code sets up whenever a frame is created for a particular client: (frame-parameter nil 'environment) This should then hold ...
Stefan's user avatar
  • 26.5k
2 votes

server-start with dynamic server-name

You can replace the call (server-start) with following code in your init.el: (require 'server) (defun my--server-start () (let ((server-num 0)) (while (server-running-p (unless (eq ...
jue's user avatar
  • 4,576
2 votes

server-start with dynamic server-name

How to determine if serverN is already launched? server-running-p is a compiled Lisp function in ‘server.el’. (server-running-p &optional NAME) Test whether server NAME is running. Return ...
phils's user avatar
  • 51.5k
2 votes

Cannot start emacs server

It's a bug. Upgrade to Emacs-25 to see if we fixed it already, and if not please M-x report-emacs-bug.
Stefan's user avatar
  • 26.5k
2 votes
Accepted

On emacs26, is it possible to halt initializing and attach to running emacs-server with init.el?

If your init file is being evaluated, then you are starting a server, not a client. Or you are starting a non-server instance of Emacs. Your init file is not looked at by emacsclient (and there is ...
phils's user avatar
  • 51.5k
2 votes
Accepted

How to enable markdown-mode every time I invoke Emacs Anywhere?

Inspection of the github page you linked to shows that Emacs Anywhere already provides hooks for this purpose and examples of their use. Look here: https://github.com/zachcurry/emacs-anywhere#hooks.
Fran Burstall's user avatar
2 votes

How to make Emacs run from a single Gnome desktop icon?

I have a solution based on comments. Since for some unclear reason starting Emacs activates the Emacsclient icon, an idea was to use directly the Emacsclient icon, with the difficulty that ...
Pierre ALBARÈDE's user avatar
2 votes
Accepted

custom-set-faces not working for client

Add (add-hook 'emacs-startup-hook (lambda () (custom-set-faces "Put your original “(custom-set-faces ...)” here!"))) to your configuration. I guess the ...
shynur's user avatar
  • 5,318
1 vote

On one specific machine, after some time, new emacsclients can no longer connect to running daemon/server

Probably running out of I/O's? lsof(8) or ulimit might provide more information
dkluenter's user avatar

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