Subject: bug#8795: 24.0.50; `completion-try-completion' addition of METADATA arg

From: "Drew Adams" <[email-masked]>
Date: Mon, 6 Jun 2011 08:29:51 -0700

> > 1. The addition of arg METADATA, without making it optional, breaks
> > existing code that calls the function with only the first four args.
>  
> Indeed, it was meant as an internal function, tho clearly it was never
> fully internal since icomplete uses it.
> 
> I'll see how I can fix it, but in the mean time, could you tell me how
> you use it (I can guess the "where" is "icicles")?

I use it here:

1. icomplete+.el
http://www.emacswiki.org/emacs/icomplete%2b.el
in the Emacs 23+ definition of `icomplete-completions':

(let* ((mdata  (and (fboundp 'completion--field-metadata)
                    (completion--field-metadata
                     (field-beginning))))
       (most-try
        (if (fboundp 'completion--field-metadata) ; Emacs 24
            (completion-try-completion
             name comps nil (length name) mdata)
          (completion-try-completion
           name comps nil (length name))))
...

2. icicles-fn.el
http://www.emacswiki.org/emacs/icicles-fn.el
in the definitions of `icicle-completion-(all|try)-completion(s)':

(let* ((mdata  (and (fboundp 'completion--field-metadata)
                    (or metadata  (completion--field-metadata
                                   (field-beginning)))))
       (res    (if (fboundp 'completion--field-metadata) ; Emacs 24
                   (completion-all-completions
                    string table pred point mdata)
                 (completion-all-completions
                  string table pred point))))
...

[similarly for `...try...']

Functions `icicle-completion-(all|try)-completion(s)' are used by functions
`icicle-unsorted(-file-name)-prefix-candidates',
`icicle-prefix-any(-file-name)-candidates-p' (in the same file).

Here is a typical use:

(if (icicle-not-basic-prefix-completion-p)
    (icicle-completion-try-completion
     input minibuffer-completion-table
     minibuffer-completion-predicate
     (length input)
     (and (fboundp 'completion--field-metadata)
          (completion--field-metadata ; Emacs 24
           (field-beginning))))
  (try-completion input minibuffer-completion-table
                  minibuffer-completion-predicate))

`icicle-not-basic-prefix-completion-p' returns non-nil if the user chooses to
take advantage of Emacs 23+ `completion-styles' etc.