[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
default file name to buffer name (was: reverting/notifying of files that
From: |
Juri Linkov |
Subject: |
default file name to buffer name (was: reverting/notifying of files that no longer exist) |
Date: |
Mon, 12 Jul 2004 19:28:28 +0300 |
User-agent: |
Gnus/5.110002 (No Gnus v0.2) Emacs/21.3.50 (gnu/linux) |
BTW, I'd like to suggest other improvements in `basic-save-buffer':
1. Add a default value to the minibuffer asking for the file name of
the buffer not visiting any file. It makes sense to use the buffer
name as the default value of the file name.
2. Currently, if the user specifies the directory name in the minibuffer
asking for the file name, then the user is asked later about
overwriting the existing directory with a new file. Since overwriting
a directory with a file is too dangerous (or not possible at all
on some systems), it is better to treat directory names specially
and to ask the user about saving the file with the name composed
from the specified directory name and the current buffer name.
Index: lisp/files.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/files.el,v
retrieving revision 1.707
diff -c -r1.707 files.el
*** lisp/files.el 26 Jun 2004 14:41:13 -0000 1.707
--- lisp/files.el 12 Jul 2004 15:17:43 -0000
***************
*** 3074,3084 ****
(or buffer-file-name
(let ((filename
(expand-file-name
! (read-file-name "File to save in: ") nil)))
! (and (file-exists-p filename)
! (or (y-or-n-p (format "File `%s' exists; overwrite? "
! filename))
! (error "Canceled")))
(set-visited-file-name filename)))
(or (verify-visited-file-modtime (current-buffer))
--- 3074,3092 ----
(or buffer-file-name
(let ((filename
(expand-file-name
! (read-file-name
! (format "File to save in (default %s): " (buffer-name))
! nil (expand-file-name (buffer-name))))))
! (if (file-exists-p filename)
! (if (file-directory-p filename)
! (let ((new-name (concat (file-name-as-directory
filename)
! (buffer-name))))
! (if (y-or-n-p (format "Save as %s? " new-name))
! (setq filename new-name)
! (error "Canceled")))
! (or (y-or-n-p (format "File %s exists; overwrite? "
! filename))
! (error "Canceled"))))
(set-visited-file-name filename)))
(or (verify-visited-file-modtime (current-buffer))
--
Juri Linkov
http://www.jurta.org/emacs/