Subject: bug#59674: 28.2; icomplete-force-complete Incorrectly Completes Filename Case

From: Cameron Norton <[email-masked]>
Date: Mon, 28 Nov 2022 19:55:06 -0800

Using icomplete, I often navigate to certain files by using a single
character for each component of the path name before completing with
icomplete-force-complete, which I have bound to <tab> while in the
minibuffer. So a file

./foo/bar/baz/asdf.txt

would be visited via the sequence

C-x C-f f/b/b/a <tab> <return>

Using icomplete-force-complete this way emulates the <tab> behavior in
completion packages like Vertico without the extra dependency.

However, with completion case sensitivity disabled, this sometimes
results in the file's path being completed incorrectly with regards to
capitalization. This is very noticeable when finding files in the usual
subdirectories of $HOME, with ~/doc <tab> completing to ~/documents/
rather than ~/Documents/, for example.

I can consistently reproduce this behavior through these steps. I have
done this on both my usual Emacs 28.2 as well as the git master
(currently 7939184).

 1. Start a clean emacs via emacs -Q.

 2. Evaluate the following:
      (icomplete-mode)
      (setq read-file-name-completion-ignore-case t)

 3. Navigate to some subdirectory of $HOME via M-x cd or equivalent.

 4. Start using C-x C-f to find a file in a different subdirectory of
    $HOME. The target file should be located in a subdirectory that
    starts with a capital letter (e.g. start finding something under
    ~/Documents somewhere).

 5. Enter the file's pathname relative to the home directory (starting
    with ~/) or an abbreviation like above using all lowercase
    letters. Do not use any completion while doing so, and do not clear
    the minibuffer of the current non-home directory beforehand.

 6. Complete the whole filename using icomplete-force-complete, which is
    bound to C-M-i by default.

An example run on my machine has me cd to ~/Downloads

M-x cd <return> ~/Downloads <return>

then try to find the file ~/Documents/Misc/asdf.org by entering

C-x C-f ~/d/m/a C-M-i

This instead completes to ~/documents/Misc/asdf.org, with "Documents"
uncapitalized but the other components completing with proper
capitalization.

(Apologies if this sent twice, I'm having unrelated technical issues.)

Cameron Norton

---

In GNU Emacs 28.2 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6)
 of 2022-09-12 built on frederik
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Arch Linux

Configured using:
 'configure --with-x-toolkit=gtk3 --with-native-compilation
 --sysconfdir=/etc --prefix=/usr --libexecdir=/usr/lib
 --localstatedir=/var --with-cairo --with-harfbuzz --with-libsystemd
 --with-modules 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt
 -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security
 -fstack-clash-protection -fcf-protection -g
 -ffile-prefix-map=/build/emacs/src=/usr/src/debug -flto=auto'
 'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -flto=auto''

Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ JPEG
JSON LCMS2 LIBOTF LIBSYSTEMD LIBXML2 M17N_FLT MODULES NATIVE_COMP NOTIFY
INOTIFY PDUMPER PNG RSVG SECCOMP SOUND THREADS TIFF TOOLKIT_SCROLL_BARS
X11 XDBE XIM XPM GTK3 ZLIB

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

Major mode: ELisp/d

Minor modes in effect:
  icomplete-mode: t
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  show-paren-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  indent-tabs-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny rfc822 mml mml-sec epa
derived epg rfc6068 epg-config gnus-util rmail vc-git diff-mode
vc-dispatcher mm-decode mm-bodies mm-encode mail-parse rfc2231
mailabbrev gmm-utils mailheader sendmail org-element avl-tree generator
ol-rmail ol-mhe ol-irc ol-info rmail-loaddefs auth-source eieio
eieio-core eieio-loaddefs password-cache rfc2047 rfc2045 ietf-drums
text-property-search mail-utils mm-util mail-prsvr wid-edit ol-docview
doc-view jka-compr image-mode exif dired dired-loaddefs ol-bibtex
ol-bbdb ol-w3m ol-doi org-link-doi org ob ob-tangle ob-ref ob-lob
ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete
pcomplete comint ansi-color ring org-list org-faces org-entities
noutline outline easy-mmode org-version ob-emacs-lisp ob-core ob-eval
org-table oc-basic json map bibtex iso8601 time-date ol org-keys oc
org-compat advice org-macs org-loaddefs format-spec find-func cal-menu
calendar cal-loaddefs icomplete comp comp-cstr warnings subr-x rx cl-seq
cl-macs cl-extra help-mode seq byte-opt gv cl-loaddefs cl-lib bytecomp
byte-compile cconv 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 cl-generic 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 simple abbrev obarray cl-preloaded nadvice button
loaddefs faces cus-face macroexp files window text-properties overlay
sha1 md5 base64 format env code-pages mule custom widget
hashtable-print-readable backquote threads dbusbind inotify lcms2
dynamic-setting system-font-setting font-render-setting cairo
move-toolbar gtk x-toolkit x multi-tty make-network-process
native-compile emacs)

Memory information:
((conses 16 182238 12573)
 (symbols 48 17422 0)
 (strings 32 55330 1555)
 (string-bytes 1 1877711)
 (vectors 16 29245)
 (vector-slots 8 520890 14491)
 (floats 8 109 254)
 (intervals 56 630 0)
 (buffers 992 14))