Stefan Monnier | 8 Feb 04:33
Picon

Re: Inner workings of `pcomplete'

> 1. emacs -Q
> 2. M-: (boundp 'pcomplete-stub) RET ==> nil
> 3. M-x shell
> 4. M-: (boundp 'pcomplete-stub) RET ==> t
> 5. M-: (special-variable-p 'pcomplete-stub) RET ==> nil
> 6. Open the file `pcomplete.el' (for example, by looking up the variable
> `pcomplete-stub') and M-x eval-buffer.  Now (special-variable-p
> 'pcomplete-stub) evaluates to t.

> What is going on here?

Duh!  Thanks for catching this.  Please M-x report-emacs-bug!

> prompt and M-: (pcomplete-completions)).  However, it is also passed as
> a table argument to the function `complete-with-action', whose
> documentation says that this argument should not be a function.

The docstring is wrong, as the first line of the code indicates ;-)

        Stefan

Oleksandr Manzyuk | 9 Feb 02:02
Picon

Re: Inner workings of `pcomplete'

On Wed, Feb 8, 2012 at 3:33 AM, Stefan Monnier <monnier <at> iro.umontreal.ca> wrote:
>> 1. emacs -Q
>> 2. M-: (boundp 'pcomplete-stub) RET ==> nil
>> 3. M-x shell
>> 4. M-: (boundp 'pcomplete-stub) RET ==> t
>> 5. M-: (special-variable-p 'pcomplete-stub) RET ==> nil
>> 6. Open the file `pcomplete.el' (for example, by looking up the variable
>> `pcomplete-stub') and M-x eval-buffer.  Now (special-variable-p
>> 'pcomplete-stub) evaluates to t.
>
>> What is going on here?
>
> Duh!  Thanks for catching this.  Please M-x report-emacs-bug!

Done.

>> prompt and M-: (pcomplete-completions)).  However, it is also passed as
>> a table argument to the function `complete-with-action', whose
>> documentation says that this argument should not be a function.
>
> The docstring is wrong, as the first line of the code indicates ;-)

Huh, indeed.  Then I rephrase my question:
`pcomplete-completions-at-point' can return non-nil even when there
are no completions, which is easy to test: in a shell buffer, I type,
say, 5, and hit TAB.  Assuming that there are no files in the current
directory starting with 5, there will be no matches.  However, if I
evaluate (pcomplete-completions-at-point), I get some hairy data
structure.  This means, in particular, that the functions in
`comint-dynamic-complete-functions' that appear after the function
(Continue reading)

Stefan Monnier | 9 Feb 22:44
Picon

Re: Inner workings of `pcomplete'

> Huh, indeed.  Then I rephrase my question:
> `pcomplete-completions-at-point' can return non-nil even when there
> are no completions,

Indeed.  What it means is that pcomplete takes responsibility for the
completion at point, including saying "no completions".

> which is easy to test: in a shell buffer, I type,
> say, 5, and hit TAB.  Assuming that there are no files in the current
> directory starting with 5, there will be no matches.  However, if I
> evaluate (pcomplete-completions-at-point), I get some hairy data
> structure.  This means, in particular, that the functions in
> `comint-dynamic-complete-functions' that appear after the function
> `pcomplete-completions-at-point' are not tried.

The completion code performs completion in several steps.
The first is "what field am I on", where the answer is "a field from
BEG..END that contains elements of type FOO".  If you want to say "I'm
not sure which type it is, could be FOO or BAR", you'll have to do that
explicitly: there's no automatic fallback along the lines of "he said
it's a field of FOOs, but there's no matching FOO so we'll see if
someone else has another opinion".

Maybe your problem is pcomplete-default-completion-function, which by
default always assumes responsibility for completion.  E.g. in shell.el
we set it via

   (set (make-local-variable 'pcomplete-default-completion-function) #'ignore)

-- Stefan
(Continue reading)


Gmane