[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Creating an empty file
From: |
Michaël Cadilhac |
Subject: |
Re: Creating an empty file |
Date: |
Tue, 23 Jan 2007 18:57:33 +0100 |
User-agent: |
Gnus/5.110006 (No Gnus v0.6) Emacs/22.0.92 (gnu/linux) |
Jay Belanger <address@hidden> writes:
> David Kastrup <address@hidden> 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?
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 ----
(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 <address@hidden>
+
+ * 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.
+
--
| 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: address@hidden' -- Dan Jacobson - --'
pgpIP1Hf33gWz.pgp
Description: PGP signature
- Re: Creating an empty file, Jay Belanger, 2007/01/23
- Re: Creating an empty file, David Kastrup, 2007/01/23
- Re: Creating an empty file, Giorgos Keramidas, 2007/01/24
- Re: Creating an empty file, Kevin Rodgers, 2007/01/25
- Re: Creating an empty file, Romain Francoise, 2007/01/25
- Re: Creating an empty file, Stefan Monnier, 2007/01/25
- Re: Creating an empty file, Richard Stallman, 2007/01/25
- Re: Creating an empty file, martin rudalics, 2007/01/25
- Re: Creating an empty file, Alfred M. Szmidt, 2007/01/25