Subject: bug#38056: 27.0.50; dired.c changes introduced autocompletion error

From: Pankaj Jangid <[email-masked]>
Date: Mon, 04 Nov 2019 10:52:09 +0530

I have tried it in various ways. The checkin
84a3793b194efe92e2eb80cd0f625f3324bf4cae have introduced autocompletion
issues at various places. To reproduce, I have tried these steps. I have
also tried it on one previous commit
(3c86424a182892db1e0216b9aa7e8389ae6f13de). This commit is ok; which
implies that the issues has occurred in commit
84a3793b194efe92e2eb80cd0f625f3324bf4cae only.

(1) launched emacs using "./src/emacs -Q".
(2) (setq debug-on-error t).
(3) C-x C-f and then type few characters of some file and TAB. This
produces same error. autocompletion on directories is working fine.
OR
(3) Tried to rename a file in dired. Press R, press few characters of
the file, press TAB. This produces error. I have debug-on-error set to
t.

produces this error:

Debugger entered--Lisp error: (args-out-of-range "a.txt" 3 2)
  file-name-completion("a" "~/work/temp/" file-exists-p)
  completion-file-name-table("~/work/temp/a" file-exists-p nil)
  try-completion("~/work/temp/a" completion-file-name-table file-exists-p)
  completion-basic-try-completion("~/work/temp/a" completion-file-name-table file-exists-p 13)
  #f(compiled-function (style) #<bytecode 0x1feff2fe885d>)(basic)
  completion--some(#f(compiled-function (style) #<bytecode 0x1feff2fe885d>) (basic partial-completion emacs22))
  completion--nth-completion(1 "~/work/temp/a" read-file-name-internal file-exists-p 13 (metadata (category . file) (completion--unquote-requote . t)))
  completion-try-completion("~/work/temp/a" read-file-name-internal file-exists-p 13 (metadata (category . file) (completion--unquote-requote . t)))
  completion--do-completion(18 31)
  completion--in-region-1(18 31)
  #f(compiled-function (start end collection predicate) #<bytecode 0x40fb4a4b>)(18 31 read-file-name-internal file-exists-p)
  apply(#f(compiled-function (start end collection predicate) #<bytecode 0x40fb4a4b>) (18 31 read-file-name-internal file-exists-p))
  #f(compiled-function (funs global args) #<bytecode 0x1feff2fe879d>)(nil nil (18 31 read-file-name-internal file-exists-p))
  completion--in-region(18 31 read-file-name-internal file-exists-p)
  completion-in-region(18 31 read-file-name-internal file-exists-p)
  minibuffer-complete()
  funcall-interactively(minibuffer-complete)
  call-interactively(minibuffer-complete nil nil)
  command-execute(minibuffer-complete)
  read-from-minibuffer("Rename a.txt to: " "~/work/temp/" (keymap (keymap (32)) keymap (menu-bar keymap (minibuf "Minibuf" keymap (tab menu-item "Complete" minibuffer-complete :help "Complete as far as possible") (space menu-item "Complete Word" minibuffer-complete-word :help "Complete at most one word") (63 menu-item "List Completions" minibuffer-completion-help :help "Display all possible completions") "Minibuf")) (27 keymap (118 . switch-to-completions)) (prior . switch-to-completions) (63 . minibuffer-completion-help) (32 . minibuffer-complete-word) (9 . minibuffer-complete) keymap (menu-bar keymap (minibuf "Minibuf" keymap (previous menu-item "Previous History Item" previous-history-element :help "Put previous minibuffer history element in the min...") (next menu-item "Next History Item" next-history-element :help "Put next minibuffer history element in the minibuf...") (isearch-backward menu-item "Isearch History Backward" isearch-backward :help "Incrementally search minibuffer history backward") (isearch-forward menu-item "Isearch History Forward" isearch-forward :help "Incrementally search minibuffer history forward") (return menu-item "Enter" exit-minibuffer :key-sequence "\15" :help "Terminate input and exit minibuffer") (quit menu-item "Quit" abort-recursive-edit :help "Abort input and exit minibuffer") "Minibuf")) (10 . exit-minibuffer) (13 . exit-minibuffer) (7 . abort-recursive-edit) (C-tab . file-cache-minibuffer-complete) (9 . self-insert-command) (XF86Back . previous-history-element) (up . previous-line-or-history-element) (prior . previous-history-element) (XF86Forward . next-history-element) (down . next-line-or-history-element) (next . next-history-element) (27 keymap (60 . minibuffer-beginning-of-buffer) (114 . previous-matching-history-element) (115 . next-matching-history-element) (112 . previous-history-element) (110 . next-history-element))) nil file-name-history "~/work/temp/a.txt" nil)
  completing-read-default("Rename a.txt to: " read-file-name-internal file-exists-p nil "~/work/temp/" file-name-history "~/work/temp/a.txt" nil)
  completing-read("Rename a.txt to: " read-file-name-internal file-exists-p nil "~/work/temp/" file-name-history "~/work/temp/a.txt")
  read-file-name-default("Rename a.txt to: " "/Users/pankaj/work/temp/" "/Users/pankaj/work/temp/a.txt" nil nil nil)
  read-file-name("Rename a.txt to: " "/Users/pankaj/work/temp/" "/Users/pankaj/work/temp/a.txt" nil nil nil)
  ido-read-file-name("Rename a.txt to: " "/Users/pankaj/work/temp/" "/Users/pankaj/work/temp/a.txt" nil nil nil)
  apply(ido-read-file-name ("Rename a.txt to: " "/Users/pankaj/work/temp/" "/Users/pankaj/work/temp/a.txt" nil nil nil))
  #f(advice-wrapper :override read-file-name-default ido-read-file-name)("Rename a.txt to: " "/Users/pankaj/work/temp/" "/Users/pankaj/work/temp/a.txt" nil nil nil)
  read-file-name("Rename a.txt to: " "/Users/pankaj/work/temp/" "/Users/pankaj/work/temp/a.txt")
  apply(read-file-name ("Rename a.txt to: " "/Users/pankaj/work/temp/" "/Users/pankaj/work/temp/a.txt"))
  dired-mark-pop-up(nil move ("a.txt") read-file-name "Rename a.txt to: " "/Users/pankaj/work/temp/" "/Users/pankaj/work/temp/a.txt")
  dired-mark-read-file-name("Rename %s to: " "/Users/pankaj/work/temp/" move nil ("a.txt") "/Users/pankaj/work/temp/a.txt")
  dired-do-create-files(move dired-rename-file "Move" nil t "Rename")
  dired-do-rename(nil)
  funcall-interactively(dired-do-rename nil)
  call-interactively(dired-do-rename nil nil)
  command-execute(dired-do-rename)

====

In GNU Emacs 27.0.50 (build 17, x86_64-apple-darwin19.0.0, NS appkit-1894.10 Version 10.15.1 (Build 19B88))
 of 2019-11-04 built on Pankajs-MacBook-Pro.local
Repository revision: 84a3793b194efe92e2eb80cd0f625f3324bf4cae
Repository branch: HEAD
Windowing system distributor 'Apple', version 10.3.1894
System Description:  Mac OS X 10.15.1

user-error: The mark is not set now, so there is no region
Making completion list...

Configured using:
 'configure CPPFLAGS=-I/usr/local/opt/ruby/include
 LDFLAGS=-L/usr/local/opt/ruby/lib'

Configured features:
RSVG DBUS GLIB NOTIFY KQUEUE ACL GNUTLS LIBXML2 ZLIB TOOLKIT_SCROLL_BARS
NS MODULES THREADS JSON PDUMPER LCMS2 GMP

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

Major mode: Lisp Interaction

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-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
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml easymenu mml-sec password-cache epa derived epg
epg-config gnus-util rmail rmail-loaddefs text-property-search time-date
subr-x seq byte-opt gv bytecomp byte-compile cconv mm-decode mm-bodies
mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader cl-loaddefs
cl-lib sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils
tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type
mwheel term/ns-win ns-win ucs-normalize mule-util term/common-win
tool-bar dnd fontset image regexp-opt fringe tabulated-list replace
newcomment text-mode elisp-mode lisp-mode prog-mode register page
tab-bar menu-bar rfn-eshadow isearch timer select scroll-bar mouse
jit-lock font-lock syntax facemenu 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 charscript charprop case-table epa-hook jka-cmpr-hook help
simple abbrev obarray cl-preloaded nadvice loaddefs button faces
cus-face macroexp files text-properties overlay sha1 md5 base64 format
env code-pages mule custom widget hashtable-print-readable backquote
threads dbusbind kqueue cocoa ns lcms2 multi-tty make-network-process
emacs)

Memory information:
((conses 16 45311 7352)
 (symbols 48 6067 1)
 (strings 32 15289 1854)
 (string-bytes 1 502990)
 (vectors 16 10184)
 (vector-slots 8 129631 5746)
 (floats 8 19 44)
 (intervals 56 217 0)
 (buffers 1000 13))

-- 
Pankaj Jangid