unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Juri Linkov <juri@jurta.org>
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	[thread overview]
Message-ID: <87n0259olv.fsf@mail.jurta.org> (raw)
In-Reply-To: <87y8lp9p2e.fsf@mail.jurta.org> (Juri Linkov's message of "Mon, 12 Jul 2004 19:18:33 +0300")

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/

  reply	other threads:[~2004-07-12 16:28 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-09 15:47 suggestion: reverting/notifying of files that no longer exist Karl Chen
2004-07-12 16:18 ` Juri Linkov
2004-07-12 16:28   ` Juri Linkov [this message]
2004-07-14  0:17     ` default file name to buffer name (was: reverting/notifying of files that no longer exist) Richard Stallman
2004-07-12 19:00   ` suggestion: reverting/notifying of files that no longer exist Karl Chen
2004-07-14 14:17     ` Juri Linkov
2004-07-14 17:30       ` Karl Chen
2004-07-15 18:42         ` i18n (was: reverting/notifying of files that no longer exist) Juri Linkov
2004-07-14  0:16   ` suggestion: reverting/notifying of files that no longer exist Richard Stallman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87n0259olv.fsf@mail.jurta.org \
    --to=juri@jurta.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).