I have a particular buffer that collects statistics from my emacs sessions. I could write the buffer every time I update the statistics, but that's not efficient. I want to auto-write the buffer whenever I quit emacs.
I have normal auto-saving turned off. (And besides, auto-saving is not the same as save-automatically-on-exit.)
I've read up on things like
kill-buffer-hook and even
local-write-files-hook, but none of them do the job and fire at the right time. In particular, I get the usual "Buffer XX is modified do you want to save it?" prompt before the
kill-emacs-hook is run.
I would rather catch and save the buffer before those exit prompts run, but I could also attach a local hook to the stats file when I first read it into my session.
Is there any recommended way to do this kind of thing (save on an exit event, or get ahead of that prompt, rather than auto-save-on-a-timer)? Thanks
Here's the kind of thing I'm looking for, but this is for shell process buffers, not for normal buffers.
;; don't prompt me when I try to quit a shell buffer (add-hook 'comint-exec-hook (lambda () (set-process-query-on-exit-flag (get-buffer-process (current-buffer)) nil)))