Mercurial > emacs
changeset 51381:a2b5bb57e1c9
(custom-get-fresh-buffer): Be extra paranoid,
just in case some used a file of the wrong name.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Sun, 01 Jun 2003 18:40:10 +0000 |
parents | 0254c3b1ede8 |
children | e099ac71bd76 |
files | lisp/cus-edit.el |
diffstat | 1 files changed, 10 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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)))