[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [emacs-wiki-discuss] Don't lose your *Remember* buffer
From: |
Frederik Fouvry |
Subject: |
Re: [emacs-wiki-discuss] Don't lose your *Remember* buffer |
Date: |
Wed, 24 Nov 2004 11:13:11 +0100 (CET) |
,-- On Tue, 23 Nov 2004 16:49:38 -0500, Andrew J. Korty wrote:
[...]
| I use the following in .emacs to keep me from accidentally destroying
| a *Remember* buffer by exiting Emacs. There's also something for Gnus
| in there. Is there a better way? If not, enjoy.
|
| ,----
| | (defun my-cleanup-then-save-buffers-kill-emacs (&optional arg)
| | "Clean up before saving buffers and killing Emacs."
| | (interactive "P")
| | ;; stop here if there's a *Remember* buffer
| | (if (get-buffer remember-buffer)
| | (remember)
| | ;; clean up Gnus
| | (and
| | (fboundp 'gnus-alive-p)
| | (gnus-alive-p)
| | (let ((gnus-interactive-exit nil))
| | (gnus-group-exit)))
| | (save-buffers-kill-emacs arg)))
| | (global-set-key "\C-x\C-c" 'my-cleanup-then-save-buffers-kill-emacs)
| `----
There is a hook (_of course_ there is one! ;-) `kill-emacs-hook' for
doing things on exit, and another (kill-emacs-query-functions) one for
querying the user about killing Emacs (in certain circumstances).
Adding your function one of to the hook will be more robust a setup
(no key redefinition needed, and the same behaviour whichever way you
exit Emacs).
The last variable (which is run by save-buffers-kill-emacs) is
probably the best one for the remember function (e.g.
(defun remember-not-active-p ()
(not (get-buffer remember-buffer)))
), kill-emacs-hook (run by `kill-emacs') is probably best for the gnus
thing (because it is not interactive).
Cheers,
Frederik Fouvry