From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.devel Subject: Re: TODO: insert-file should warn if the file is modified Date: Fri, 19 Apr 2002 09:47:06 -0400 Sender: emacs-devel-admin@gnu.org Message-ID: References: Reply-To: Eli Zaretskii NNTP-Posting-Host: localhost.gmane.org X-Trace: main.gmane.org 1019224128 29491 127.0.0.1 (19 Apr 2002 13:48:48 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Fri, 19 Apr 2002 13:48:48 +0000 (UTC) Cc: emacs-devel@gnu.org Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by main.gmane.org with esmtp (Exim 3.33 #1 (Debian)) id 16yYkp-0007fY-00 for ; Fri, 19 Apr 2002 15:48:47 +0200 Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby.gnus.org with esmtp (Exim 3.12 #1 (Debian)) id 16yZ4D-0000Hz-00 for ; Fri, 19 Apr 2002 16:08:49 +0200 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.34 #1 (Debian)) id 16yYkb-0008Dd-00; Fri, 19 Apr 2002 09:48:33 -0400 Original-Received: from eliz by fencepost.gnu.org with local (Exim 3.34 #1 (Debian)) id 16yYjC-0007yl-00; Fri, 19 Apr 2002 09:47:06 -0400 Original-To: Pavel@Janik.cz In-Reply-To: (Pavel@Janik.cz) Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.9 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: main.gmane.org gmane.emacs.devel:2781 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:2781 > From: Pavel@Janik.cz (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?