We’re rewarding the question askers & reputations are being recalculated! Read more.

Hot answers tagged

21

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 ...


16

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 #!/usr/bin/env xdg-open [Desktop Entry] Version=1.0 Name=GNU Emacs 24 GenericName=Text Editor Comment=View and edit files MimeType=text/english;text/plain;text/x-makefile;text/x-c++hdr;...


13

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.


9

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 (...


9

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


9

Simply use (daemonp) which will return t if emacs is running as a daemon.


8

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 ...


7

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-...


7

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: setup.el: (require 'server) (setq server-name "sx-test" ; name of the server ...


6

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 ...


6

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.


6

Don't kill the process. Use M-x kill-emacs RET to terminate the server.


5

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 ...


5

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." (interactive) (with-selected-frame frame (when (daemonp) (if (not (boundp 'server-wg)) (progn (wg-create-workgroup "server"...


4

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" ...


4

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 ...


4

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" (with-selected-frame frame (if (display-graphic-...


4

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. ls ...


4

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 "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 (...


3

Edit: This question has several answers, which generally seem to boil down to "use after-frame-functions". Original answer: 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 ...


3

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 ...


3

emacsclient and TRAMP Automatically open remote files in local emacs I have had success with the first solution. The second seems to be simpler, I'm yet to try it out.


3

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 ...


2

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 ...


2

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: cp /usr/share/...


2

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 <...


2

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. (1) ...


2

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 (lambda () (when (find-font (font-spec :name "Symbola")) ...


2

Our discussion cleared that you do not have any X-server running this renders my first solution useless for you. In the following I present a second solution that works with text terminal frames. When your initialization requires user input through one the functions advised with avoid-initial-terminal Emacs waits until you open a text terminal frame. The ...


2

The things that I did on the @DoMiNeLa10's advice: Set (add-to-list 'default-frame-alist '(font . "SF Mono-14")) instead of (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 ...


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