Frage

I need to call "my-global-modified-flag-update" function before closing Emacs (C-x C-c). This function marks as unmodified the buffers that I don't need to save, thus avoiding Emacs to ask me for. Of course it must run as first task, before Emacs asks me about save files.

This is my easy solution for keyboard command "C-x C-c" (save-buffers-kill-terminal)

(defun my-kill-emacs()
   (interactive)
   (my-global-modified-flag-update)
   (save-buffers-kill-terminal))
(global-set-key (kbd "C-x C-c") 'my-kill-emacs)

How to do the same when closing Emacs by mouse? (clicking on the windows top right X)

War es hilfreich?

Lösung

The easiest option I can think of, if hooks are not enough for you, would be to advice save-buffers-kill-emacs.

Try this:

(defadvice save-buffers-kill-emacs (before update-mod-flag activate)
    (my-global-modified-flag-update))

Andere Tipps

Don't do it that way at all. Just use kill-emacs-hook or kill-emacs-query-functions. See the Elisp manual, node Killing Emacs.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top