Subject: Re: bug#6299: In read-file-name: (args-out-of-range "c:" 0 3)

From: Lennart Borgman <[email-masked]>
Date: Sun, 30 May 2010 00:07:16 +0200

On Sat, May 29, 2010 at 11:24 PM, Lennart Borgman
<[email-masked]> wrote:
> On Sat, May 29, 2010 at 11:18 PM, Stefan Monnier
> <[email-masked]> wrote:
>>> Debugger entered--Lisp error: (args-out-of-range "c:" 0 3)
>>>   signal(args-out-of-range ("c:" 0 3))
>>>   completion--some(#[(style) "        \236A@\n \f
>>> $\207" [style completion-styles-alist string table pred point] 5]
>>> (basic partial-completion emacs22))
>>
>> First thing: edit completion--some o as to replace condition-case with
>> condition-case-no-debug.  This way the error won't be delayed and you'll
>> get a more precise backtrace.

eval-buffer in minibuffer.el made it more understandable. Here it is
(but I do not know the cause of it):

* I added a little trace here

(defun completion-pcm--find-all-completions (string table pred point
                                                    &optional filter)
  "Find all completions for STRING at POINT in TABLE, satisfying PRED.
POINT is a position inside STRING.
FILTER is a function applied to the return value, that can be used, e.g. to
filter out additional entries (because TABLE migth not obey PRED)."
  (unless filter (setq filter 'identity))
  (message "FIND: filter=%S" filter)
  (let* ((beforepoint (substring string 0 point))
         (afterpoint (substring string point))
         (bounds (completion-boundaries beforepoint table pred afterpoint))
         (dummy (message "FIND: string=%S bounds=%S, beforepoint=%S
afterpoint=%S" string bounds beforepoint afterpoint))
         (prefix (substring beforepoint 0 (car bounds)))
         (suffix (substring afterpoint (cdr bounds)))
         firsterror)

and in

(defun completion-boundaries (string table pred suffix)
  "Return the boundaries of the completions returned by TABLE for STRING.
STRING is the string on which completion will be performed.
SUFFIX is the string after point.
The result is of the form (START . END) where START is the position
in STRING of the beginning of the completion field and END is the position
in SUFFIX of the end of the completion field.
E.g. for simple completion tables, the result is always (0 . (length SUFFIX))
and for file names the result is the positions delimited by
the closest directory separators."
  (message "BOUNDARIES string=%S table=%s pred=%s suffix=%S" string
table pred suffix)
  (let ((boundaries (if (functionp table)
                        (funcall table string pred (cons 'boundaries suffix)))))
    (message "BOUNDARIES boundaries=%S" boundaries)
    (if (not (eq (car-safe boundaries) 'boundaries))
        (setq boundaries nil))
    (cons (or (cadr boundaries) 0)
          (or (cddr boundaries) (length suffix)))))

and got

BOUNDARIES string="c:/ema" table=read-file-name-internal
pred=file-exists-p suffix=""
BOUNDARIES boundaries=(boundaries 3)
FIND: filter=completion-pcm--filename-try-filter
BOUNDARIES string="c:/ema" table=read-file-name-internal
pred=file-exists-p suffix=""
BOUNDARIES boundaries=(boundaries 3)
FIND: string="c:/ema" bounds=(3 . 0), beforepoint="c:/ema" afterpoint=""
FIND: prefix="c:/"
FIND: substring="c:"
FIND: filter=completion-pcm--filename-try-filter
BOUNDARIES string="c:" table=read-file-name-internal
pred=file-exists-p suffix=""
BOUNDARIES boundaries=(boundaries 3)
FIND: string="c:" bounds=(3 . 0), beforepoint="c:" afterpoint=""
Entering debugger...

It looks like perhaps read-file-name-internal gives the wrong information.

PS: There is an advice on read-file-name is

  Around-advice `viper-suffix-advice':
  Tell `exit-minibuffer' to run `viper-file-add-suffix' as a hook.

which does not seem to be involved (I unadvised read-file-name).