Subject: 29.1; WDired uses `substitute-in-file-name', so `$$' is changed to `$' - undocumented?

From: Drew Adams <[email-masked]>
Date: Fri, 24 Nov 2023 23:35:54 +0000

emacs -Q

C-x d aaa   ; Go to a directory with a file named `aaa'

C-x C-q

Append $$$$ to the file name, to give `aaa$$$$'

C-x C-q

The resulting file was named `aaa$$', not `aaa$$$$'.

It seems that every occurrence of `$$' in a file name is treated as just
`$'.  (The position of the `$$' in the new file name seems to be
irrelevant.)

I see this in older Emacs releases as well.  I found nothing in the doc
that would indicate that this is supposed to happen (and preferably
why).  And the only occurrence of char `$' in wdired.el seems benign.

Ah, I found it - it comes from `substitute-in-file-name':

  (substitute-in-file-name "aa$$$$") ; -> "aa$$"

But is that appropriate behavior in this context?  If it is, then maybe
the doc should tell you what to do if you want literal `$' chars.  (I
tried escaping with `\$`, but that ended up being changed to `/' and
changing the file to an empty directory!)

OK, the doc of `substitute-in-file-name' says to use `$$' to get a
single `$'.  So that's clear enough.  But what's not clear from the
WDired doc is that that function is used (instead of `expand-file-name')
by WDired.

The WDired doc is pretty scant, overall.  This, at least, should be
mentioned I think.  And any other gotchas - special (non-literal)
treatment of the text used in file names.  That would include use of
`\' as a directory separator on MS Windows, I suppose.

In GNU Emacs 29.1 (build 2, x86_64-w64-mingw32) of 2023-08-02 built on
 AVALON
Windowing system distributor 'Microsoft Corp.', version 10.0.19045
System Description: Microsoft Windows 10 Pro (v10.0.2009.19045.3570)

Configured using:
 'configure --with-modules --without-dbus --with-native-compilation=aot
 --without-compress-install --with-tree-sitter CFLAGS=-O2'

Configured features:
ACL GIF GMP GNUTLS HARFBUZZ JPEG JSON LCMS2 LIBXML2 MODULES NATIVE_COMP
NOTIFY W32NOTIFY PDUMPER PNG RSVG SOUND SQLITE3 THREADS TIFF
TOOLKIT_SCROLL_BARS TREE_SITTER WEBP XPM ZLIB

(NATIVE_COMP present but libgccjit not available)

Important settings:
  value of $LANG: ENU
  locale-coding-system: cp1252