8
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♦
- 33.3k
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."...
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.
...
6
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 ...
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 '...
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 ...
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 "...
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♦
- 33.3k
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 ...
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")))
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 ...
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 ...
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 ...
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 ...
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 $...
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, ...
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 ...
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 ...
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.
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 ...
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.
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 ...
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 ...
2
votes
emacsclient says "No connection could be made.."
In the *Warnings* buffer I found following warning:
Warning (server): Unable to start the Emacs server.
There is an existing Emacs server, named "server".
To start the server in this Emacs ...
1
vote
Emacs client doesn't recognize non-ascii input
Does this fix the problem?
(defun my-terminal-keyboard-coding-system (&optional frame)
"Force the terminal `keyboard-coding-system' to be `utf-8'.
Prevents terminal frames using a coding ...
1
vote
How to open multiple files from desktop in the same emacs session?
The details will depend on the particular file browser you're using, but you need to set the default program for opening text files to emacsclient, rather than emacs.
1
vote
Accepted
emacsclientw does not use font specified in init.el (Windows)
I used default-frame-alist and it solves the issue.
(add-to-list 'default-frame-alist '(font . "Courier New-14")) ;; Font type & size
It is guaranteed to work, whether Emacs is launched normally ...
1
vote
When `emacs` is started, use `emacsclient` instead if there is a server
The alternative-editor option supports this. The following invocation does what you describe:
emacsclient -a""
This opens emacsclient, and starts the server if it isn't already running.
See the ...
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
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
server × 86emacsclient × 42
emacs-daemon × 12
init-file × 8
microsoft-windows × 8
frames × 5
daemon × 5
osx × 4
command-line-arguments × 4
org-mode × 3
buffers × 3
faces × 3
ssh × 3
x11 × 3
hooks × 2
fonts × 2
use-package × 2
shell-command × 2
lsp-mode × 2
remote × 2
session × 2
web × 2
spacemacs × 1
org-babel × 1
python × 1