Subject: bug#76182: 31.0.50; minibuffer-allow-text-properties not reliable

From: Juri Linkov <[email-masked]>
Date: Tue, 11 Feb 2025 19:14:05 +0200

>> Despite what the docstring says, setting the variable to t does not seem
>> to be reliable.  Take the following scenario:
>> 
>>         1. emacs -Q
>>         2. Paste in
>>             (let ((cand (list (propertize "test" 'prop 1)
>>                               (propertize "test1" 'prop 2))))
>>               (minibuffer-with-setup-hook
>>                   (lambda ()
>>                     (setq-local minibuffer-allow-text-properties t))
>>                 (get-text-property 0 'prop (completing-read "test: " cand nil t))))
>>            *scratch* buffer or wherever.
>>         3. Evaluate the form.
>>         4. In the minibuffer prompt, type "test" then press RET.
>>         5. Observe how the return value is nil.
>>         6. Evaluate the form again but this time press TAB and RET.
>>         7. Observe how it returns 1 as expected.
>>         8. Evaluate the form again but this time type "te", press TAB,
>>            type "1" and press RET.
>>         9. Observe how it returns nil.  Here if you examine the string
>>            returned, you will find that the text-property is retained
>>            only for indices 2--5.
>> 
>> Is this expected?  I would expect the form to always return the value of
>> the property 'prop' regardless how I completed the string.
>
> Juri, any comments?

This reminds the recent discussion at
https://lists.gnu.org/archive/html/emacs-devel/2024-05/msg00819.html
that required documenting this limitation in the docstring of
'imenu-flatten':

  Since the values `annotation' and `group' rely on text properties,
  you can use them only by selecting candidates from the completions
  buffer, not by typing in the minibuffer.  This also means that
  if you use `minibuffer-next-completion' (`M-<down>') to select
  a completion while point stays in the minibuffer, you need
  to customize `minibuffer-completion-auto-choose' to nil that
  doesn't insert completion candidates to the minibuffer.