bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#8897: `completion--insert-strings' clobbers user-added text properti


From: Stefan Monnier
Subject: bug#8897: `completion--insert-strings' clobbers user-added text properties
Date: Mon, 20 Jun 2011 12:36:37 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)

>>> #+begin_src elisp
>>> (let ((req (assoc-default n minibuffer-completion-table)))
>>> (concat " "
>>> (propertize (plist-get req :title)
>>> 'fontified t
>>> 'button '(t)
>>> 'category 'default-button
>>> 'help-echo "RET or mouse-2 for details"
>>> 'pr-data req
>>> 'action (lambda (b) (magithub-pull-request-details
>>> (button-get b 'pr-data))))))
>>> #+end_src
>> 
>> I must be missing something: where is a `face' or `mouse-face' property
>> added?  The above code should not be affected by your patch, AFAICT.
>> And I don't understand your comment about "but the button functions seem
>> to set up the button face automatically" since I don't see where you
>> call a button function before insertion.

> Sorry for my confusing description. What I meant is that there is
> apparently some magic involved that makes a string manufactured with a
> `propertize' form like the one above appear as if it had the button face
> (underlined), even though it's not explicitely among its text properties
> (maybe the `category' does it? I don't know).

Yes, the `category' property is special and is "equivalent" to adding
all the properties on the symbol used for the category (i.e. all the
properties on the `default-button' symbol in your above example), which
most likely includes `face' and/or `mouse-face' properties.

> In any case, without my patch the face is overridden to become the usual
> annotation italic, so it _does_ suffer from the problem I describe.

Right, the `face' text-property takes precedence over the `face'
property provided by the `category' text property.  Hmm...

> Indeed. I don't use the cursor keys, but you're right in that they seem
> to include the button-like annotations among their jump targets; as for
> `choose-completion', that seems to be bound to RET in the *Completions*
> buffer, but as I said and in line with your guess, pressing RET on an
> annotation actually invokes the button action as desired, so this
> problem doesn't seem to occur.

Yes, when point is on the button, RET (and mouse clicks) does not call
choose-completion but the button command instead.  But if you have bound
choose-completion to some other keys that are not overridden by the
button, you'll see the problem (or if you do M-x choose-completion).


        Stefan





reply via email to

[Prev in Thread] Current Thread [Next in Thread]