Subject: bug#65719: [PATCH] Pass restart argument to 'kill-emacs-query-functions'

From: Eli Zaretskii <[email-masked]>
Date: Sat, 04 Jan 2025 16:14:17 +0200

> Date: Sat, 04 Jan 2025 13:34:23 +0000
> From: [email-masked]
> Cc: [email-masked], [email-masked]
> 
> > Sorry, I still don't follow.  What does your
> > kill-emacs-query-functions hook do when passed the RESTART argument
> > that is different from RESTART being nil (i.e. killing Emacs without
> > restarting it)?
> 
> The point is differentiating between a quick "Oh I just need to clear 
> out some memory or reset the state of my Emacs, but I want to carry on 
> working as I was" and "I'm done with Emacs now, next time I start it I 
> want it to be a clean slate". Adding another hook was the cleanest 
> option I could come up with.

It's a strange (and maybe even dangerous) distinction.

But in any case, I think a cleaner solution would be to bind a
variable inside restart-emacs, and then your hook could examine it.
Alternatively, ...

> > In any case, the prefix argument is available via current-prefix-arg.
> 
> Yes you're right, I realised after I sent it....

...you could invoke restart-emacs with a prefix argument, and examine
that in your kill-emacs-query-functions hook.  AFAICT, this should
work without any changes.