From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Luc Teirlinck Newsgroups: gmane.emacs.devel Subject: dired.el Date: Sun, 6 Jun 2004 14:26:48 -0500 (CDT) Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: <200406061926.i56JQmL28247@raven.dms.auburn.edu> NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1086550124 23033 80.91.224.253 (6 Jun 2004 19:28:44 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 6 Jun 2004 19:28:44 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Sun Jun 06 21:28:37 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BX3Js-0001Rx-00 for ; Sun, 06 Jun 2004 21:28:36 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BX3Js-00071O-00 for ; Sun, 06 Jun 2004 21:28:36 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BX3KN-0003xB-KG for emacs-devel@quimby.gnus.org; Sun, 06 Jun 2004 15:29:07 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BX3KH-0003wm-0c for emacs-devel@gnu.org; Sun, 06 Jun 2004 15:29:01 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BX3KG-0003wQ-0V for emacs-devel@gnu.org; Sun, 06 Jun 2004 15:29:00 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BX3KF-0003w9-Ue for emacs-devel@gnu.org; Sun, 06 Jun 2004 15:28:59 -0400 Original-Received: from [131.204.53.104] (helo=manatee.dms.auburn.edu) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BX3JN-0007Er-2l for emacs-devel@gnu.org; Sun, 06 Jun 2004 15:28:05 -0400 Original-Received: from raven.dms.auburn.edu (raven.dms.auburn.edu [131.204.53.29]) by manatee.dms.auburn.edu (8.12.10/8.12.10) with ESMTP id i56JRuuE022147 for ; Sun, 6 Jun 2004 14:27:57 -0500 (CDT) Original-Received: (from teirllm@localhost) by raven.dms.auburn.edu (8.11.6+Sun/8.11.6) id i56JQmL28247; Sun, 6 Jun 2004 14:26:48 -0500 (CDT) X-Authentication-Warning: raven.dms.auburn.edu: teirllm set sender to teirllm@dms.auburn.edu using -f Original-To: emacs-devel@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:24615 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:24615 While fixing bugs in Dired, locate and find-dired, I noticed the following two problems, which were both present before my changes. The small patch below corrects both. I will install if it seems OK. Make a directory. say ~/subdir, say using + in Dired and then make files ~/testfile and ~/subdir/testfile. (It is very common to have files with the same name in different directories.) Visit ~/ using Dired. Then insert ~/subdir using `i'. "Accidentally" kill it using C-u k on the subdirectory header line. Reinsert it using `C-_'. First (minor) problem: occasionally the mode line marks the Dired buffer as writable for some period before correcting it. The Dired buffer is not really writable during that period, the modeline was just updated at the wrong time. Now the real problem. Delete the "testfile" entry in the inserted subdir. Now ~/testfile and not ~/subdir/testfile is deleted. All kind of other serious damage can occur in the given situation, the above is just an example. It can be argued that this is not a bug. It is mentioned in the docstring of `dired-undo': Undo in a dired buffer. This doesn't recover lost files, it just undoes changes in the buffer itself. You can use it to recover marks, killed lines or subdirs. In the latter case, you have to do M-x dired-build-subdir-alist to parse the buffer again. But not everybody reads the docstring of every single command before using it. `dired-undo' is documented in the Emacs manual and _there_ `dired-build-subdir-alist' does not seem to be mentioned at all. Given the danger involved in failing to call `dired-build-subdir-alist' in the given situation, why not simply make `dired-undo' call `dired-build-subdir-alist'? The patch below does this. As an added bonus, it also corrects the modeline problem. (To be honest, I do not fully understand why, but it does. The patch changes the scope of the buffer-read-only binding. Does message update modelines?) ===File ~/dired-diff======================================== *** dired.el 05 Jun 2004 19:54:59 -0500 1.287 --- dired.el 06 Jun 2004 12:20:04 -0500 *************** *** 1453,1461 **** parse the buffer again." (interactive) (let (buffer-read-only) ! (undo) ! (message "Change in Dired buffer undone. ! Actual changes in files cannot be undone by Emacs."))) (defun dired-next-line (arg) "Move down lines then position at filename. --- 1453,1462 ---- parse the buffer again." (interactive) (let (buffer-read-only) ! (undo)) ! (dired-build-subdir-alist) ! (message "Change in Dired buffer undone. ! Actual changes in files cannot be undone by Emacs.")) (defun dired-next-line (arg) "Move down lines then position at filename. ============================================================