unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: michael@cadilhac.name (Michaël Cadilhac)
Cc: emacs-devel@gnu.org
Subject: Re: Creating an empty file
Date: Tue, 23 Jan 2007 18:57:33 +0100	[thread overview]
Message-ID: <87r6tlpqwi.fsf@lrde.org> (raw)
In-Reply-To: <87y7ntd5jq.fsf@vh213602.truman.edu> (Jay Belanger's message of "Tue\, 23 Jan 2007 11\:19\:37 -0600")


[-- Attachment #1.1.1: Type: text/plain, Size: 808 bytes --]

Jay Belanger <belanger@truman.edu> writes:

> David Kastrup <dak@gnu.org> writes:
> ...
>> This would probably also apply for an existing file that has been
>> changed on disk, but not in the Emacs buffer.  In this case it might
>> possibly make sense to ask the "revert buffer" question before saving.
>> In the case of a non-existing file, there is nothing to revert to,
>> however.
>
> So are you suggesting that when saving a file whose buffer has not
> been changed, that Emacs should compare it to the disk file anyhow?
> I had always (always=for the last 10 seconds) thought that it didn't
> for efficiency reasons.

Well, the modification flag has a certain use that should be
preserved. What may be done is to add a var
`new-files-are-already-modified'.

Maybe the (untested) following could help?


[-- Attachment #1.1.2: files.patch --]
[-- Type: text/x-patch, Size: 2083 bytes --]

Index: lisp/files.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/files.el,v
retrieving revision 1.879
diff -c -r1.879 files.el
*** lisp/files.el	21 Jan 2007 03:53:11 -0000	1.879
--- lisp/files.el	23 Jan 2007 17:56:38 -0000
***************
*** 1751,1756 ****
--- 1751,1764 ----
  \f
  (defvar after-find-file-from-revert-buffer nil)
  
+ (defcustom new-files-are-already-modified nil
+   "Non-nil means that new files are set to be modified.
+ This can be useful if you want to create empty files without actually
+ modify the buffer."
+   :group 'files
+   :version "22.1"
+   :type 'boolean)
+ 
  (defun after-find-file (&optional error warn noauto
  				  after-find-file-from-revert-buffer
  				  nomodes)
***************
*** 1787,1793 ****
  		  (format "%s has auto save data; consider M-x recover-this-file"
  			  (file-name-nondirectory buffer-file-name))
  		(setq not-serious t)
! 		(if error "(New file)" nil)))
  	     ((not error)
  	      (setq not-serious t)
  	      "Note: file is write protected")
--- 1795,1804 ----
  		  (format "%s has auto save data; consider M-x recover-this-file"
  			  (file-name-nondirectory buffer-file-name))
  		(setq not-serious t)
! 		(when error
! 		  (when new-files-are-already-modified
! 		    (set-buffer-modified-p 'set))
! 		  "(New file)")))
  	     ((not error)
  	      (setq not-serious t)
  	      "Note: file is write protected")
Index: lisp/ChangeLog
===================================================================
RCS file: /sources/emacs/emacs/lisp/ChangeLog,v
retrieving revision 1.10592
diff -C0 -r1.10592 ChangeLog
*** lisp/ChangeLog	23 Jan 2007 07:18:50 -0000	1.10592
--- lisp/ChangeLog	23 Jan 2007 17:56:56 -0000
***************
*** 0 ****
--- 1,6 ----
+ 2007-01-23  Michaël Cadilhac  <michael.cadilhac@lrde.org>
+ 
+ 	* files.el (new-files-are-already-modified): New.  This customizable
+ 	variable tells if new files are to be considered as modified.
+ 	(after-find-file): Handle it.
+ 

[-- Attachment #1.1.3: Type: text/plain, Size: 331 bytes --]


-- 
 |      Michaël `Micha' Cadilhac     |  Isn't vi that text editor with        |
 |         Epita/LRDE Promo 2007     |   two modes... One that beeps and      |
 |  http://michael.cadilhac.name     |     one that corrupts your file?       |
 `--JID: michael.cadilhac@gmail.com--'           -- Dan Jacobson         -  --'

[-- Attachment #1.2: Type: application/pgp-signature, Size: 188 bytes --]

[-- Attachment #2: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

  parent reply	other threads:[~2007-01-23 17:57 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <86bqkphiyj.fsf@lola.quinscape.zz>
     [not found] ` <87odopr8ga.fsf@lrde.org>
2007-01-23 16:35   ` Creating an empty file Jay Belanger
2007-01-23 16:48     ` David Kastrup
2007-01-23 17:19       ` Jay Belanger
2007-01-23 17:23         ` David Kastrup
2007-01-23 17:57         ` Michaël Cadilhac [this message]
2007-01-23 23:56           ` David Kastrup
2007-01-24  1:19             ` Stefan Monnier
2007-01-24  7:12               ` martin rudalics
2007-01-24  2:58           ` Giorgos Keramidas
2007-01-25  9:06             ` Kevin Rodgers
2007-01-25 10:36               ` Romain Francoise
2007-01-25 19:39                 ` Stefan Monnier
2007-01-25 21:44                 ` Richard Stallman
2007-01-25 22:01                   ` martin rudalics
2007-01-25 22:07                     ` Alfred M. Szmidt
2007-01-25 22:14                       ` Lennart Borgman (gmail)
2007-01-26 11:43                     ` Richard Stallman
2007-01-25 22:14               ` Piet van Oostrum
2007-01-23 18:20       ` Michaël Cadilhac
2007-01-23 16:49     ` Leo
2007-01-23 17:11       ` David Kastrup
2007-01-23 21:57       ` Phil Jackson
2007-01-24  7:37         ` David Kastrup

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=87r6tlpqwi.fsf@lrde.org \
    --to=michael@cadilhac.name \
    --cc=emacs-devel@gnu.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).