Subject: bug#68814: 29.1; dired fails to mark links to . or .. for deletion

From: Eli Zaretskii <[email-masked]>
Date: Sat, 03 Feb 2024 12:40:34 +0200

> Date: Mon, 29 Jan 2024 21:36:04 -0600
> From: Devon Sean McCullough <[email-masked]>
> 
> $ mkdir /tmp/scratch
> $ cd /tmp/scratch
> $ ln -s . self
> $ ln -s .. up
> $ ln -s ... ...
> $ emacs .
> Type the letter d three times.
> Dired fails to mark all three files for deletion, unlike prior versions.

Thanks.  This is the (unintended) result of fixing bug#38729.

How does the patch below look?  Do you see any possible problems with
it?  That is, would exempting symlinks from the dot-dot rule cause any
problems?

diff --git a/lisp/dired.el b/lisp/dired.el
index c33569d..d9fbafb 100644
--- a/lisp/dired.el
+++ b/lisp/dired.el
@@ -4110,6 +4110,11 @@ dired-mark
        (prefix-numeric-value arg)
        (lambda ()
          (when (or (not (looking-at-p dired-re-dot))
+                   ;; Don't skip symlinks to ".", "..", etc.
+                   (save-excursion
+                     (re-search-forward
+                      dired-permission-flags-regexp nil t)
+                     (eq (char-after (match-beginning 1)) ?l))
                    (not (equal dired-marker-char dired-del-marker)))
            (delete-char 1)
            (insert dired-marker-char))))))))