emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

23.0.50; Deleting files in wdired does not work


From: Phil Sung
Subject: 23.0.50; Deleting files in wdired does not work
Date: Mon, 21 Jan 2008 00:41:18 -0500

Marking files for deletion in wdired by deleting their filenames (as
advertised in wdired.el and in the Info) does not work.

Steps to reproduce:

Open a directory in dired, e.g.: C-x C-f ~/wd/test RET

Change to wdired mode: M-x wdired-change-to-wdired-mode

The buffer looks like this:

  /home/phil/wd/test:
  total used in directory 8 available 130996008
  drwxr-xr-x  2 phil phil 4096 2008-01-20 22:51 .
  drwxr-xr-x 15 phil phil 4096 2008-01-20 03:34 ..
  -rw-r--r--  1 phil phil    0 2008-01-20 22:51 bar
  -rw-r--r--  1 phil phil    0 2008-01-20 22:51 foo

Delete a filename, like so:

  /home/phil/wd/test:
  total used in directory 8 available 130996008
  drwxr-xr-x  2 phil phil 4096 2008-01-20 22:51 .
  drwxr-xr-x 15 phil phil 4096 2008-01-20 03:34 ..
  -rw-r--r--  1 phil phil    0 2008-01-20 22:51
  -rw-r--r--  1 phil phil    0 2008-01-20 22:51 foo

Save the changes: C-c C-c

The buffer now looks like this:

  /home/phil/wd/test:
  total used in directory 8 available 130996008
  drwxr-xr-x  2 phil phil 4096 2008-01-20 22:52 .
  drwxr-xr-x 15 phil phil 4096 2008-01-20 03:34 ..
  -rw-r--r--  1 phil phil    0 2008-01-20 22:51

  -rw-r--r--  1 phil phil    0 2008-01-20 22:51 foo

Expected output-- the file name should have been restored and the file
marked for deletion:

  /home/phil/wd/test:
  total used in directory 8 available 130984448
  drwxr-xr-x  2 phil phil 4096 2008-01-20 23:11 .
  drwxr-xr-x 15 phil phil 4096 2008-01-20 03:34 ..
D -rw-r--r--  1 phil phil    0 2008-01-20 23:11 bar
  -rw-r--r--  1 phil phil    0 2008-01-20 23:11 foo


It looks like wdired-get-filename adds a spurious newline to the result
whenever the filename has been deleted in wdired. In addition, in
wdired-finish-edit, to test whether a filename has been deleted, we should look
at (wdired-get-filename t), which returns the basename only, and see whether it
equals "".

I propose the following patch:


*** lisp/wdired.el      8 Jan 2008 20:44:46 -0000       1.33
--- lisp/wdired.el      21 Jan 2008 05:03:35 -0000
***************
*** 324,328 ****
        (if old
            (setq file (get-text-property beg 'old-name))
!         (setq end (next-single-property-change (1+ beg) 'end-name))
          (setq file (buffer-substring-no-properties (1+ beg) end)))
        (and file (setq file (wdired-normalize-filename file))))
--- 324,332 ----
        (if old
            (setq file (get-text-property beg 'old-name))
!         (setq end (min (line-end-position)
!                        ; n-s-p-c can return nil on the last filename in the
!                        ; buffer when that filename has been deleted
!                        (or (next-single-property-change (1+ beg) 'end-name)
!                            (point-max))))
          (setq file (buffer-substring-no-properties (1+ beg) end)))
        (and file (setq file (wdired-normalize-filename file))))
***************
*** 390,394 ****
        (when (and file-ori (not (equal file-new file-ori)))
          (setq changes t)
!         (if (not file-new)            ;empty filename!
              (setq files-deleted (cons file-ori files-deleted))
            (setq file-new (substitute-in-file-name file-new))
--- 394,398 ----
        (when (and file-ori (not (equal file-new file-ori)))
          (setq changes t)
!         (if (zerop (length (wdired-get-filename t))) ; empty filename
              (setq files-deleted (cons file-ori files-deleted))
            (setq file-new (substitute-in-file-name file-new))


---

In GNU Emacs 23.0.50.3 (i686-pc-linux-gnu, GTK+ Version 2.12.3)
 of 2008-01-20 on phil
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8
  default-enable-multibyte-characters: t

Major mode: Dired

Minor modes in effect:
  shell-dirtrack-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  unify-8859-on-encoding-mode: t
  utf-translate-cjk-mode: t
  auto-compression-mode: t
  line-number-mode: t

Recent input:
C-a C-f C-f C-f ESC : ESC p C-e RET C-e DEL DEL DEL
DEL DEL DEL C-a ESC : ESC p C-e ESC O D SPC t C-e RET
C-e a C-a ESC : ESC p C-e RET C-e DEL C-x o C-s w d
i r e d - g e t - f i l e n a m e C-s C-s C-s C-s C-s
C-s C-s C-s C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p C-p
C-p C-p C-n C-n C-n C-p C-p C-p C-n C-x b w d i r e
d l DEL . e l RET C-n C-s w d i r e d - g e t - f i
l e n a m e C-n C-n C-n C-n C-n C-n C-n C-n C-n C-n
C-n C-n C-n C-n C-p C-p C-p ESC C-x C-n C-n C-p C-e
C-p C-e C-n C-n C-p C-p C-a C-e C-a C-n C-e C-a C-p
C-e C-a C-e C-a C-n C-e C-a C-p C-e C-a C-n C-e C-a
C-p C-e C-a C-n C-e C-a C-p C-e C-a C-n C-p C-n C-p
C-s w d i r e d - f i n i s h - e d i t C-s C-r C-r
C-n ESC C-x C-x o C-c ESC C-n g C-x C-q C-e C-p DEL
DEL DEL C-x C-s C-n C-n C-p C-p C-p C-n C-n C-n C-p
C-p C-p C-p C-p C-n C-n C-n C-n C-n C-p C-p C-p C-p
C-p C-p C-n C-n C-n C-n C-n C-n C-p C-p C-p C-p C-p
C-n C-n C-n C-n C-n ESC x r e p o r t - e m a c s -
b u g TAB RET

Recent messages:
"/home/phil/wd/test/abcdef"
" [2 times]
"a"
Mark saved where search started [2 times]
wdired-get-filename
Mark saved where search started
wdired-finish-edit
Changes aborted
Press C-c C-c when finished or C-c ESC to abort changes
Source file `/home/phil/source/emacs/lisp/mail/sendmail.el' newer than
byte-compiled file




reply via email to

[Prev in Thread] Current Thread [Next in Thread]