Emacs is a big, complicated program. It must know how to handle large text files, and to interact with users in a graphical user interface or in a text terminal. It can display graphics. On my machine, it loads 34 libraries just in order to start. The binary is 15 megabytes. Many people, myself included, only start emacs once in a rare while, and hardly ever ...
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 before the initial frame opens.
There you can try:
(if (server-running-p "server")
(let ((file-name (expand-file-name (car (cdr command-line-...
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 ...
This problem was also reported as an issue (see spacemacs issue #7078). The solution of using a wrapper script posted there worked for me. For completeness I will add the content of the script here:
if [[ "$#" -lt 1 ]] ; then
emacsclient -c -e \
"(select-frame-set-input-focus (selected-frame))" \
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 ...
You do not need to modify web-mode.el.
You just add a new font-lock keyword in web-mode-hook.
The code below demonstrates that. You can store it in your init file.
(defface my-web-mode-hl__lg '((t (:foreground "#ff007c")))
"Face for the first arg of __lg.")
(defun my-web-mode-hl__lg ()
"Configure web mode such that the first arg of __lg(...) is high-...
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, ...
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 nothing you can put into your init file which could transform the emacs instance which is evaluating it into a client of some other instance -- and even if there ...
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 it:
When compiled with GTK, Emacs cannot recover from X disconnects.\n\
This is a GTK bug: https://bugzilla.gnome.org/show_bug.cgi?id=85715\n\
For details, see ...
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 ...
That's correct. The emacsclient binary is not present in the source src directory. It is however present in the lib-src directory. So do a make install, if you have not already done so, to put the emacsclient binary in your build directory, wherever you have chosen that to be.
Here is an with-undo-collapse macro that uses Emacs-26 change-groups feature.
This is atomic-change-group with a one line change, adding undo-amalgamate-change-group.
It has the advantages that:
It doesn't need to manipulate the undo data directly.
It ensures undo data isn't truncated.
(defmacro with-undo-collapse (&rest body)
"Like `progn' but ...
I figured out why .bashrc solution didn't work. I had to actually export the variables:
export EDITOR="emacsclient -nw"
I use -nw both for $EDITOR & $VISUAL since I don't want to involve my emacs frame as much as possible.
The alternative-editor option supports this. The following invocation does what you describe:
This opens emacsclient, and starts the server if it isn't already running.
See the manual for details: https://www.gnu.org/software/emacs/manual/html_node/emacs/Invoking-emacsclient.html
along with a message about the desktop file already being in use
Emacsclient does not attempt to process the desktop file, so you are clearly starting a new instance of Emacs.
If emacsclient can't connect to the server, but you either passed it -a '' or --alternate-editor='' or else have the ALTERNATE_EDITOR environment variable set to an empty string, ...
So at the end I used the idea proposed by @lawlist: I just put (remove-hook 'kill-emacs-hook 'pcache-kill-emacs-hook) at the end of my .emacs. I'm not sure what was meant by "keep in mind, that you must unload it after the pcache library loads it" as I'm not that well versed in emacs/lisp. However what I was looking for is achieved even if this solution ...
In my question I said that I cannot use --debug-init with emacsclient but I was wrong, I can indeed use --debug-init.
emacsclient, per its man page, possibly starts Emacs as emacs -daemon and this is is equivalent, as I've found, to emacs -nw -daemon, so that every init file code that references frame/desktop stuff is bound to fail...
But I can use emacs --...
Try bisecting your init file (.emacs), to see which part of it causes the problem:
Comment out 1/2 of it, and try that with emacsclient to see which 1/2 is problematic.
Then comment out 1/4 of it, and try emacsclient again, to see which 1/4 is problematic.
Then 1/8, 1/16, 1/32,...
At the very least this will remove most of your init file from the problem ...
This is a kind of quirky way of achieving it, but it worked for me.
Having frame-title-format set to its original value:
(setq frame-title-format '(multiple-frames "%b"
("" invocation-name "@" system-name)))
shows this on wmctrl utility to interact with X-Windows manager:
$ wmctrl -l
0x00e00003 0 ES-00002604 /...
The answer has two parts.
The function get-file-buffer returns the buffer visiting the file given as argument or nil if there is no such buffer. You can use it in the following way:
(require 'subr-x) ;; for `when-let'
(when-let ((buf (get-file-buffer file-name))
(win (get-buffer-window buf)))
You do actually not need get-file-buffer ...
You do not need anything as fancy as a virtual environment:
Create a folder (e.g. =mkdir ~/Test; mkdir ~/Test/Emacs26= in a terminal);
Compile (or copying a compiled executable) the version of Emacs that you want to test in it (e.g. =Emacs 26.1=). You might find the instructions from Xah Lee on ErgoEmacs useful (http://ergoemacs.org/emacs/...
C-x C-c will not prompt to ask for saving desktop, it will exit Emacs immediately.
C-xC-c (save-buffers-kill-terminal) does not actually kill the server by default, unless the client invoking it was started with the --no-wait switch and there are no other remaining Emacs frames.
Is there anything I can do to prompt for confirmation when C-x C-c in ...
I found the answer from https://emacs.stackexchange.com/a/30475/794
The version is tweaked version from the answer in the link
(defun ask-before-closing ()
"Prompt for confirmation for emacsclient(not daemon) like confirm-kill-emacs for running Emacs without daemon."
(if (y-or-n-p (format "Really exit Emacs? "))
The command I use is:
emacsclientw.exe --create-frame --no-wait --alternate-editor runemacs.exe --server-file %APPDATA%\.emacs.d\server\server
(If the Emacs bin folder is not on your PATH, use the full paths for emacsclientw.exe and runemacs.exe.)
or with the short option names and the empty string trick,
emacsclientw.exe -c -n -a "" -f %APPDATA%\.emacs....
I think defering the prompts is going to be difficult in general, but it should be fairly easy to change Emacs so that such prompts immediately signal an error.
Not only that, but if you can't answer those prompts without a lot of gymnastics, I think it qualifies as a bug, so I'd recommend you submit a bug report for that.