You can use kill-emacs-hook which is run when emacs is quit 'normally'.
Hook run when kill-emacs is called. Since kill-emacs may be
invoked when the terminal is disconnected (or in other similar
situations), functions placed on this hook should not expect to be
able to interact with the user. To ask for confirmation, see
You can use this to exit from your init file:
(with-current-buffer " *load*"
Emacs uses the load function to execute lisp file through a temporary buffer, that's " *load*", if the name is not already taken. The above code moves the point to the end of the buffer, thus the read function will not read further code.
For example, ...
This is explained in the manual here:
C-hig (emacs)emacsclient Options RET
The new graphical or text terminal frames created by the ‘-c’ or ‘-t’
options are considered “client frames”. Any new frame that you create
from a client frame is also considered a client frame. If you type ‘C-x
C-c’ (‘save-buffers-kill-terminal’) in a client frame, that ...
C-x C-c is for Kill Emacs (save-buffers-kill-terminal).
Maybe on other systems you are using emacsclient, then
C-x C-c behaves specially if you are using Emacs as a server. If you type it from a client frame, it closes the client connection.
Or maybe you run multiple instances of Emacs?
To close only one frame use C-x 5 0 or s-w.
This command delete ...
This is a commonly asked question. It might be a duplicate here (dunno). There are various tweaks or libraries that some users use to provide what you are asking - you will likely get some answers pointing to them.
But my suggestion is to not use *scratch* the way you are using it - maybe not use it at all. Instead, use C-x C-f foo.el or whatever, which ...
@Harald answered your question.
But I would not say "unfortunately". This is by design. Buffer *scratch* is designed for what its name suggests and its initial contents describe: It is a scratchpad, for throwaway content.
If you use it for some other purpose then you are misusing it.
But of course you might want a scratchpad that is automatically backed ...
Emacs 26.1 added the confirm-kill-processes variable. To disable conformation to kill processes on Emacs exit, add to your init file:
(setq confirm-kill-processes nil)
Non-nil if Emacs should confirm killing processes on exit. If this variable is nil, the value of process-query-on-exit-flag is ignored. Otherwise, if there are processes ...
Following my own suggestion (second comment on the question), here's an answer which avoids the prompting altogether:
(let ((auto-answer '(("\\`Active processes exist; kill them and exit anyway\\? \\'" t))))
This uses auto-answer.el, available at https://github.com/YoungFrog/auto-answer/blob/master/...
I use the following in my init file to solve exactly this problem. I probably cribbed this from somewhere myself but it's been so long I can't remember the source.
(defun my/org-clock-query-out ()
"Ask the user before clocking out.
This is a useful function for adding to `kill-emacs-query-functions'."
When killing Emacs, there are several hooks that may end up being called -- including, but not limited to, kill-emacs-hook, kill-buffer-hook (when a buffer is killed), write-file-functions hook (if a buffer is saved). A user can inspect a hook by calling M-x describe-variable and the name of the hook. A user can run a hook by evaluating (run-hooks NAME-OF-...
The manual explicitly states that kill-emacs is called, running the kill-emacs-hook, when SIGTERM or SIGKILL is recieved. So I would call this a bug.
(I guess this has to do with how windows kills differently than POSIX, but it should be possible to implement the analog/correct ...
What is the actual problem and what can I do about it?
The hash is only initialized in mu4e-headers-mode. Therefore, you should correct mu4e-execute-marks in the following way if you want to call it in kill-emacs-hook:
(defun mu4e-execute-marks ()
(when (derived-mode-p 'mu4e-headers-mode)
How to debug ...
Use the function kill-emacs. From its help:
kill-emacs is an interactive built-in function in `C source code'.
(kill-emacs &optional ARG)
Exit the Emacs job and kill it. If ARG is an integer, return ARG as
the exit program code. If ARG is a string, stuff it as keyboard input.
The value of `kill-emacs-hook', if not void, is a list of ...
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? "))
I think the problem is that save-buffers-kill-emacs asks that yes-or-no question. When you're asked that you must either answer yes or no or use C-g to quit (in this case, quit exiting).
You could advise or redefine save-buffers-kill-emacs to accommodate what you want. Or you could just define a command that you use after using C-g to quit exiting.
If you really want to do it, it can be done.
There are two standard hooks that you can use when emacs exits: kill-emacs-hook and kill-emacs-query-functions. The former is simple to use for always clocking out when you exit emacs:
(add-hook 'kill-emacs-hook #'org-clock-out)
List of standard hooks:
However, I would like to recommend an easy way of using emacs more efficiently.
First, you create emacs server:
This makes emacs run as daemon(server mode), which means that you have one emacs server and you can have multiple clients.
Now when you open emacs(using emacsclient -t or emacsclient -c depending on console/GUI), you create ...
Here's a command that does what you want:
(defun ora-dired-start-process (cmd &optional file-list)
(let ((files (dired-get-marked-files
(unless (eq system-type 'windows-nt)
(dired-read-shell-command "& on %s: "
Well the source of the problem was this line:
(setq help-char (kbd "<f1>"))
I changed it to
(setq help-char nil)
Well it was a kinda intuitive solution, so if another answer explains it, I will accept that.
Update with explanation:
Well I found the error, the kbd function returns with different datatypes, according to the given keys, an example:
With the suggestions of @elethan and @Tobias I was able to generate this stack-trace:
Debugger entered--Lisp error: (wrong-type-argument listp "make -k ")
call-interactively(save-buffers-kill-terminal nil nil)
And track it down to ...