# HG changeset patch # User Stefan Monnier # Date 1054492810 0 # Node ID a2b5bb57e1c95a3a09e82b8dad631bcdab574bea # Parent 0254c3b1ede8f5d2165a2c39b061301094b4bf7e (custom-get-fresh-buffer): Be extra paranoid, just in case some used a file of the wrong name. diff -r 0254c3b1ede8 -r a2b5bb57e1c9 lisp/cus-edit.el --- a/lisp/cus-edit.el Sun Jun 01 18:03:00 2003 +0000 +++ b/lisp/cus-edit.el Sun Jun 01 18:40:10 2003 +0000 @@ -1208,12 +1208,21 @@ (defun custom-get-fresh-buffer (name) "Get a fresh new buffer with name NAME. -If the buffer already exist, clean it up to be like new." +If the buffer already exist, clean it up to be like new. +Beware: it's not quite like new. Good enough for custom, but maybe +not for everybody." + ;; To be more complete, we should also kill all permanent-local variables, + ;; but it's not needed for custom. (let ((buf (get-buffer name))) + (when (buffer-local-value 'buffer-file-name buf) + ;; This will check if the file is not saved. + (kill-buffer buf) + (setq buf nil)) (if (null buf) (get-buffer-create name) (with-current-buffer buf (kill-all-local-variables) + (run-hooks 'kill-buffer-hook) (erase-buffer) (let ((ols (overlay-lists))) (dolist (ol (nconc (car ols) (cdr ols)))