5

You're probably looking for the package exec-path-from-shell. Once it's installed, put this in your .emacs: (exec-path-from-shell-initialize) for emacs to read .bashrc on startup. That way you won't have to maintain paths in two places.


5

I think daemonp is what you're looking for. From its docstring: Return non-nil if the current emacs process is a daemon. If the daemon was given a name argument, return that name.


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


4

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 argument, return that name. So: (when (daemonp) (do-server-only-stuff-here))


4

Bisecting the emacs.el init file by inserting (error "Done) to quit the init file at that location, I was able to quickly find the offending call, in my case (org-mobile-pull).


3

after-make-frame-functions is what I use in these situations. Here's an example, adapted from https://stackoverflow.com/a/5066313/324105 (defun my-frame-behaviours (&optional frame) "Make frame- and/or terminal-local changes." (with-selected-frame (or frame (selected-frame)) ;; do things... )) ;; Evaluate immediately (for non-daemon emacs), ...


3

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. The command line from which you ran emacsclient will be waiting for the file to be closed by the server, and then terminate. You won't be able to execute ...


3

This happens because your .emacs runs when the daemon is started. Usually, you start the daemon without any display system at all, and Emacs doesn't know how to make frames. After emacsclient forces Emacs to create a frame in the current session, Emacs then knows how to create frames. You can fix this by using the --eval flag of emacsclient, which evaluates ...


3

Surprisingly (at least to me), the -f flag means different things to emacs and emacsclient. To emacs, it means: -f FUNCTION --funcall=FUNCTION Call Lisp function FUNCTION. If it is an interactive function (a command), it reads the arguments interactively just as if you had called the same function with a key sequence. Otherwise, ...


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

Instead of using emacsclient -nc [file], if you remove the -n argument and do just emacsclient -c [file], you can quickly close the popped frame and buffer by calling server-edit, which is bound to C-x # by default. For instance, my workflow for editing crontab files would be: crone (aliased to setenv VISUAL emacsclient && crontab -e (tcsh)) in ...


3

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 'gnu/linux) (setq server-auth-dir "~/.emacs.d/server/"))) (setq server-name "emacs-server-file") (server-start)) Then you can get access to server with ...


3

Make sure you are using the same version of emacs and emacsclient. When my system emacsclient is used instead of my custom build emacs, I'm getting a similar error: $ /usr/bin/emacsclient --version emacsclient 22.1 $ /usr/bin/emacsclient . /usr/bin/emacsclient: can't find socket; have you started the server? To start the server in Emacs, type "M-x server-...


3

You may want to define a function that will ask you to confirm before closing a frame. Then you'll check if Emacs was started as a daemon, if it is the case, update the C-x C-c shortcut. Something in that spirit: (defun ask-before-closing () "Close only if y was pressed." (interactive) (if (y-or-n-p (format "Are you sure you want to close this frame? "...


3

The most simple solution to your actual problem -- avoiding the tool bar -- is to customize tool-bar-mode to nil. Alternatively you can also put (setq tool-bar-mode nil) into your init file. The problem with window-system in emacs daemon is that the virtual frame of the emacs daemon is not connected to any display. Since the init file runs in the daemon ...


3

Both return the same value when getenv is called on SSH_AUTH_SOCK from within an emacs client. That looks unlikely. One would return ~/.ssh/ssh_auth_sock and the other would return /path/to/HOME/.ssh/ssh_auth_sock, no? Have you tested whether SSH_AUTH_SOCK can actually contain ~ as a substitute for your HOME directory? Usually that would be expanded by a ...


2

Does this do what you're looking for? emacsclient -e '(make-frame-command)' If I do emacsclient -e '(make-frame-command)' -t it opens in a TTY instead of a new GUI frame, but then I have to do 'C-x 5 0' twice to get it to close...


2

For unfathomable reasons, this just happened to me on a FC28 upgrade of my laptop. Even stracing ddid not help. After perusing several links (this included), I came up by sticking these lines: # bash syntax # On laptop, emacscclient cannot find emacs socket any longer (after FC28) export EMACS_SERVER_SOCKET=${TMPDIR:-/tmp}/emacs$(id -u)/server alias ...


2

I used to have the same issue until I did: alias e="emacsclient -t --socket-name=/tmp/emacs1000/server" And now I just use this "e" alias to start emacsclient. I haven't seen the issue since.


2

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 server-num 0) (concat "server" (number-to-string server-num)))) (setq server-num (+ server-num 1))) (unless (eq server-num 0) (setq ...


2

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 values: nil the server is definitely not running. t the server seems to be running. something else we cannot determine whether ...


2

I suspect you have unremoved desktop lockfiles, which will usually be in your config dir/folder, which is hopefully ~/.emacs.d/. Here's a procedure for testing my hypothesis from a commandline (e.g. a Bash shell running in a terminal app under Linux): Ensure you have no emacs* processes running: i.e., there should be null response to pgrep -l emacs If you ...


2

The option -a specifies the editor that should be started if there is no emacs server started yet (the so-called "alternate editor). If the empty string is passed, as in the script above, emacs --daemon is run and emacsclient tries to connect to it (see man emacsclient or M-: (info "(emacs) emacsclient Options") within emacs). Unfortunately, in your case, ...


1

Not necessarily the answer you are looking for, but I have in exactly the same setup always used just emacsclient -c or emacsclient -t. Meaning I don't start the server manually, the first invoking of either will start the server and any subsequent invoking will connect to the server.


1

These appearance settings are controlled via frame parameters. The simple way to set them is to add the parameters you want to default-frame-alist and initial-frame-alist. The font is font and the fringe is left-fringe and right-fringe. (setq my-frame-alist '((font . "Fira Code") (left-fringe . 10) (right-fringe ...


1

Just pass --daemon to your wrapper script? You should change emacs $1 to emacs "$@" (setq use-spacemacs (getenv "USE_SPACEMACS")) (when (> (length use-spacemacs) 0) could be (when (getenv "USE_SPACEMACS")


1

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


1

Use this command to invoke the client: emacsclient -s foo -t -s is for giving a server name in contrast to -f that specifies the server file and that's a socket with full path. Emacs starts the server on a local socket (represented by a file) if available -- and with linux it is. So, no TCP socket is opened.


1

You could use a custom wrapper script as your -a argument value, but you presumably only want to use --debug-init temporarily, so... just do that. Kill your Emacs server if it's running, and then restart it with --debug-init. emacs --daemon --debug-init Now connect to it as usual. edit: TomRoche adds the following... Note that, if this throws an ...


1

I can verify that it is possible to run Emacs 24 as a daemon on Windows 10, if you use Cygwin. If you're using the Windows-native Cygwin version (Cygwin package emacs-w32), then I think you'll need to start the daemon through bash, but you can call emacsclient directly from Windows, and the resulting instances will connect to the daemon just fine.


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