[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: TODO: insert-file should warn if the file is modified
From: |
Andreas Schwab |
Subject: |
Re: TODO: insert-file should warn if the file is modified |
Date: |
Fri, 19 Apr 2002 16:33:47 +0200 |
User-agent: |
Gnus/5.090005 (Oort Gnus v0.05) Emacs/21.2.50 (ia64-suse-linux) |
Eli Zaretskii <address@hidden> writes:
|> > From: address@hidden (Pavel =?iso-8859-2?q?Jan=EDk?=)
|> > Date: Fri, 19 Apr 2002 14:58:37 +0200
|> >
|> > * If you do an insert-file and that file is currently modified in
|> > another buffer but not written yet, print a warning.
|> >
|> > I think that it is pretty simple:
|> >
|> > (defun file-is-modified-somewhere (filename)
|> > "Check if the file FILENAME is modified inside Emacs.
|> >
|> > Return buffer visiting the file FILENAME marked as modified.
|> > Otherwise, return nil."
|> > (let ((result))
|> > (dolist (buffer (buffer-list) result)
|> > (if (and (string= filename (buffer-file-name buffer))
|> > (buffer-modified-p buffer))
|> > (setq result buffer)))))
|>
|> What about buffer that visit the same file under a different name
|> (e.g., symlinks on Posix systems)? Don't we want to catch those as
|> well?
|>
|> In other words, perhaps you should base the search on file's
|> attributes, not just the name?
You can use the buffer-file-truename for that.
Andreas.
--
Andreas Schwab, SuSE Labs, address@hidden
SuSE GmbH, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."