You cannot use emacsclient to connect to an Emacs instance running on a remote computer. This client-server concept is related to (local) processes, not network nodes. However, you can use various network technologies to log in to the remote computer, attach to an emacs server running there and display the emacsclient's screen locally. Depending on the ...
I'm using Ubuntu, so the location of the desktop file may be different but I think the contents should be similar.
$ cat ~/.local/share/applications/emacsclient.desktop
Name=GNU Emacs 24
Comment=View and edit files
Use emacs --daemon=your-server-name -l "custom-init-file" to start a new server and emacsclient -nw -s your-server-name to connect to it from the terminal itself. The section on Using Emacs as a server in the manual has more initialization options.
In addition to @Vamsi's answer, you can get many of the same benefits while running only a single server by attaching advice to make-frame-command.
For example, while running in the terminal I want the background color to be black (which maps to #202020) but I want to use #202020 in a graphical mode. I implemented this with:
(defadvice make-frame-command (...
Probably not what you asked for but assuming you have ssh setup with X-forwarding, you could start emacsclient on the server and forward it to remote DISPLAY. (Disclaimer: code typed directly into webform)
local> ssh server -f emacsclient -c --display=$DISPLAY
You cannot do this using different themes. The solution is to create a theme that has different face definitions depending on the terminal. If you look at an example like font-lock-comment-face, you'll see how it works. Instead of specifying ((class color) (min-colors 88) (background dark)) you could also specifcy (type tty) or (type graphic) etc. The manual ...
This behaviour is actually a known and documented limitation of this port, see README-mac (emphasis mine):
The Mac port doesn't support multi-tty with GUI. The developer has no
idea how to detach Emacs as a GUI application from Window Server or
Dock without separating a GUI process (not thread) from the main Emacs
(Lisp evaluator) process. TTY-...
I think one of the things unclear from the FAQ is the necessity that both server and client be resolveable from each other. You can see this thread from 2009. Eventually, back then I did get it to work, but now I do see the same as the OP. This is what I tried:
(setq server-name "sx-test" ; name of the server
I really don't mind Emacs.app always running, but the fact that I couldn't close the window without accidentally killing the Emacs server was annoying. And even if you try really hard to kill the last frame, it still doesn't let you: "Attempt to delete the sole visible or iconified frame". ...So we cheat.
This solution just hides Emacs (like Command+h) when ...
color-theme-buffer-local provides buffer-local theme support for both color-theme and the Emacs 24 theme systems. My version of the solarized theme also supports both systems, if you decide to go this route.
Did you read man emacsclient?
This worked fine for me:
emacsclient --alternate-editor='' --no-wait --create-frame --frame-parameters='(quote (name . "scratchemacs-frame"))' --display $DISPLAY
The --alternate-editor parameter is there so emacsclient will start a new emacs daemon if one isn't already running, and --no-wait makes emacsclient return ...
This may be not what you want but just in case see if it can help you some way.
I usually work inside a virtual machine bootstrapped with Vagrant, I have my ~/.emacs.d directory synced between my machine (local) and the virtual machine (remote) putting the following in the Vagrantfile file:
config.vm.synced_folder "~/.emacs.d", "/home/vagrant/.emacs.d"
The Yamamoto Mitsuharu port of emacs doesn't support multi-tty unfortunately (see this issue). This means that you can't start the emacs daemon from the terminal and launch a gui window with emacsclient.
Here is what I do: In my init.el I have (server-start)and I launch Emacs.app at login. The annoyance here is that this brings up a window which I have to ...
You don't need an advice to change settings of different frames running in the same emacs daemon. Just use the hook after-make-frame-functions like so
(defvar my/ttheme 'tango-dark)
(defvar my/gtheme 'tango)
(defun my/frame-configuration (frame)
"configure the current frame depending on the frame type"
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."
(if (not (boundp 'server-wg))
By default, on a Unix-like platform, the sockets are located in a directory called /tmp/emacs1234 where /tmp is the value of the environment variable TMPDIR (defaulting to /tmp) and 1234 is your user ID. So to list daemon sockets, assuming you aren't passing any argument to emacsclient other than the daemon name, just list the contents of that directory.
Edit: This question has several answers, which generally seem to boil down to "use after-frame-functions".
I think you want to call load-theme from after-init-hook. That's where I load my own theme, and I have no problems using it with emacsclient.
I don't know the ins and outs of the Emacs initialization process well enough to say for ...
That's not exactly the answer to my question but I managed to sidestep the problem by using this solution from a post in SO. Just wanting to share the solution with the one who are still struggling with this.
The key is using dtach with tramp to keep the process alive on the remote host alive even if your disconnect from the server.
Here is the command to ...
The directory where the socket is created is controlled by this variable:
(and (featurep 'make-network-process '(:family local))
(format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid)))
"The directory in which to place the server socket.
If local sockets are not supported, this is nil.")
If you use tcp sockets (...
You can define conditions for face customizations, like "terminal mode" or "minimal colors" in the customization editor:
When customizing a face, click the [State] button and select "Show all display specs". Then you can set up the conditions for further specialization of the face.
Here's a minimal variant to set the background color
to black when the ...
I'm really just tweaking dgtized's answer to address the comment from akaihola. I.e. what we want is to
make use of Emacs's daemon functionality
summon an existing frame or create one if necessary.
I find that creating an emacs25.desktop file rather than emacsclient.desktop magically worked (frankly, I don't know why).
So I did:
I'm not sure how railwaycat Emacs is different from the regular home-brew formula, but with the latter you would do ln -sfv /usr/local/opt/emacs/*.plist ~/Library/LaunchAgents, which would run emacs --daemon on login.
The plist is included as a HERE-document in the formula. All you'd need to adopt it is change the path to your emacs app in the line <...
For a socket the permissions should be srwx------ - the s, meaning "socket" is the important part. (I also tried removing the executable bit, it didn't make a difference).
Since the permissions are -rw------- you are not using a socket. There are two ways to fix that, (1) make sure you are using a socket (2) tell emacsclient that it's not a socket.
This trick worked for me; I basically wait for emacs to be idle for a second (which happens after its startup finishes) and do the Symbola font check just once. This seems to work when emacs in launched in regular or daemon mode.
(run-with-idle-timer 1 nil
(when (find-font (font-spec :name "Symbola"))
Not exactly what you are asking for but maybe a solution to your original problem:
I'd like to know if there is a general way to keep emacs --daemon from hanging forever waiting for an answer to a prompt displayed in a minibuffer that doesn't exist yet.
If the daemon gives you a graphical frame for answering questions arising in its startup-phase you do ...
The things that I did on the @DoMiNeLa10's advice:
(add-to-list 'default-frame-alist '(font . "SF Mono-14"))
(set-face-attribute 'default nil :font "SF Mono-14")
(set-frame-font "SF Mono" nil t)
By playing around with evaluating (menu-bar-mode -1), (tool-bar-mode -1) and (scroll-bar-mode -1) I just found out that it works if I remove the ...
I imagine you have code running at init time which checks to see whether or not you are running a GUI emacs (via display-graphic-p or similar), and configures certain settings based on that.
(display-graphic-p) returns t at init time when a GUI non-daemon Emacs starts, because a graphical frame is created beforehand; but that function call returns nil at ...