Subject: bug#57293: 29.0.50; query-replace with Wdired skips symlink target

From: Mike Kupfer <[email-masked]>
Date: Thu, 18 Aug 2022 20:11:36 -0700

From "emacs -Q":

1. Create a file foo, and create a symlink bar that points to foo.

S lrwxrwxrwx  1 kupfer kupfer    3 Aug 18 19:48 bar -> foo
  -rw-r--r--  1 kupfer kupfer    0 Aug 18 19:46 foo

2. Visit the directory with dired and type C-x C-q.

3. Move point to the start of the buffer.

4. M-% foo RET baz RET

I expect query-replace to ask me about both the file foo and the symlink
target foo.  That's what Emacs 28.1 does, and it's quite handy.
Instead, query-replace asks me only about the file foo, ignoring the
symlink target.

S lrwxrwxrwx  1 kupfer kupfer    3 Aug 18 19:48 bar -> foo
  -rw-r--r--  1 kupfer kupfer    0 Aug 18 19:46 baz

I can still manually fix the symlink (replace "foo" with "baz") while in
Wdired, but I think query-replace should be able to do this for me.

The build is Emacs master 7dab52dfbc plus a couple local fixes to MH-E,
so I expect it's reproducible with just 7dab52dfbc.

In GNU Emacs 29.0.50 (build 14, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
 of 2022-08-18 built on alto
Repository revision: d3fd48a98606cd8d8de577af114ce0eb046ff210
Repository branch: master-mdk
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)

Configured using:
 'configure --prefix=/usr/new'

Configured features:
CAIRO FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG LIBSELINUX
LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PNG SECCOMP SOUND THREADS TIFF
TOOLKIT_SCROLL_BARS X11 XDBE XIM XPM LUCID ZLIB

Important settings:
  value of $LC_TIME: C
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Shell

Minor modes in effect:
  shell-dirtrack-mode: t
  delete-selection-mode: t
  global-eldoc-mode: t
  show-paren-mode: t
  mouse-wheel-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  column-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t

Load-path shadows:
None found.

Features:
(shadow mh-identity emacsbug misearch multi-isearch wdired dired-aux
dired-x shr-color color textsec uni-scripts idna-mapping ucs-normalize
uni-confusable textsec-check qp mm-archive mail-extr mh-mime pp
mule-util mh-search mh-letter mh-show goto-addr thingatpt gnus-cite
mh-thread mh-inc hl-line mh-tool-bar mh-acros mh-seq mh-xface mh-utils
mh-folder which-func imenu files-x mdk-mail gnus-mh gnus-msg mh-comp
mh-scan mh-gnus gnus-dup nnmh gnus-score score-mode gnus-art mm-uu
mml2015 mm-view mml-smime smime gnutls dig gnus-sum shr pixel-fill
kinsoku url-file svg dom browse-url url url-proxy url-privacy url-expand
url-methods url-history url-cookie generate-lisp-file url-domsuf
url-util url-parse auth-source cl-seq eieio eieio-core cl-macs json map
gv url-vars gnus-group gnus-undo gnus-start gnus-dbus dbus xml
gnus-cloud nnimap nnmail mail-source utf7 nnoo parse-time iso8601
gnus-spec gnus-int gnus-range gnus-win gnus nnheader range wid-edit mh-e
mh-buffers mh-loaddefs message sendmail mailcap yank-media puny dired
dired-loaddefs rfc822 mml mml-sec password-cache epa derived epg rfc6068
epg-config gnus-util text-property-search time-date mm-decode mm-bodies
mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums
mail-prsvr mailabbrev mail-utils gmm-utils mailheader server noutline
outline easy-mmode icons cc-mode cc-fonts cc-guess cc-menus cc-cmds
cc-styles cc-align cc-engine cc-vars cc-defs byte-opt bytecomp
byte-compile cconv shell subr-x pcomplete comint ansi-color ring xcscope
advice delsel vc vc-dispatcher timeclock cl-loaddefs cl-lib mdk-hacks
rmc iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks
lisp-float-type elisp-mode mwheel term/x-win x-win term/common-win x-dnd
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar
rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock
font-lock syntax font-core term/tty-colors frame minibuffer nadvice seq
simple cl-generic indonesian philippine cham georgian utf-8-lang
misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms
cp51932 hebrew greek romanian slovak czech european ethiopic indian
cyrillic chinese composite emoji-zwj charscript charprop case-table
epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget keymap
hashtable-print-readable backquote threads inotify dynamic-setting
system-font-setting font-render-setting cairo x-toolkit x multi-tty
make-network-process emacs)

Memory information:
((conses 16 341028 35766)
 (symbols 48 19344 2)
 (strings 32 82149 1520)
 (string-bytes 1 2322871)
 (vectors 16 64652)
 (vector-slots 8 1498444 216905)
 (floats 8 324 210)
 (intervals 56 3883 77)
 (buffers 992 24))