GNU bug report logs - #8897
`completion--insert-strings' clobbers user-added text properties

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Štěpán Němec <stepnem@HIDDEN>; dated Sun, 19 Jun 2011 18:28:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 8897 <at> debbugs.gnu.org:


Received: (at 8897) by debbugs.gnu.org; 20 Jun 2011 16:36:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 20 12:36:47 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QYhSx-0001f2-5k
	for submit <at> debbugs.gnu.org; Mon, 20 Jun 2011 12:36:47 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.181]
	helo=ironport2-out.pppoe.ca)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QYhSv-0001er-HH
	for 8897 <at> debbugs.gnu.org; Mon, 20 Jun 2011 12:36:46 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av0EANt2/01FpYrD/2dsb2JhbABTpl94iHO/N4YqBJ1ZhCI
X-IronPort-AV: E=Sophos;i="4.65,395,1304308800"; d="scan'208";a="116689314"
Received: from 69-165-138-195.dsl.teksavvy.com (HELO pastel.home)
	([69.165.138.195])
	by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA;
	20 Jun 2011 12:36:37 -0400
Received: by pastel.home (Postfix, from userid 20848)
	id 258AC59011; Mon, 20 Jun 2011 12:36:37 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
Subject: Re: bug#8897: `completion--insert-strings' clobbers user-added text
	properties
Message-ID: <jwv8vswjwxp.fsf-monnier+emacs@HIDDEN>
References: <8739j5bs01.fsf@HIDDEN> <jwvd3i9mcbm.fsf-monnier+emacs@HIDDEN>
	<87y60x9b8y.fsf@HIDDEN> <jwvwrggk3m3.fsf-monnier+emacs@HIDDEN>
	<87pqm8a8hh.fsf@HIDDEN>
Date: Mon, 20 Jun 2011 12:36:37 -0400
In-Reply-To: <87pqm8a8hh.fsf@HIDDEN> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?=
	=?utf-8?B?ZWMiJ3M=?= message of "Mon, 20 Jun 2011 16:22:02 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 8897
Cc: 8897 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.1 (--)

>>> #+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




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8897; Package emacs. Full text available.

Message received at 8897 <at> debbugs.gnu.org:


Received: (at 8897) by debbugs.gnu.org; 20 Jun 2011 14:26:19 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 20 10:26:19 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QYfQh-00006E-7p
	for submit <at> debbugs.gnu.org; Mon, 20 Jun 2011 10:26:19 -0400
Received: from mail-bw0-f44.google.com ([209.85.214.44])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stepnem@HIDDEN>) id 1QYfQe-000061-Fv
	for 8897 <at> debbugs.gnu.org; Mon, 20 Jun 2011 10:26:17 -0400
Received: by bwz13 with SMTP id 13so3570685bwz.3
	for <8897 <at> debbugs.gnu.org>; Mon, 20 Jun 2011 07:26:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:cc:subject:in-reply-to:references
	:user-agent:date:message-id:mime-version:content-type
	:content-transfer-encoding;
	bh=6ON2BTFOuhe2XczJwOUaB4ipEMRJh7Dbr8TJrMilC9k=;
	b=fBb5EGhuvgWe4R5COq9yLRWq1i8jnGI0XRWOIk8ZThj2GUQqw3ix4fmp/9NWSslMMV
	pwd1S/VnSqeYOfsybj1biLe3bVV8EksEY9uTzW6PCoX0FTWI9uZC79uGiP691MCeuQym
	L5VaHEuI58qoxLSswhR+P9uHWkXpxPWERtCb8=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:cc:subject:in-reply-to:references:user-agent:date
	:message-id:mime-version:content-type:content-transfer-encoding;
	b=xfq2xmn4DuB2QciH+mSnMHA3PY1YafiZRBNpWhxCY0I/Juk1Qr5XVSq+1/O9jsqCxc
	hzVZltHbqU/UZSa1IkHzk8SjDk8BI84bOFU9fAwnIw68ahRoO4UXcOTr96GBZEEln0D8
	ZakT6ukIzMia0kutL2kDyajylgq2OdrS4nUeI=
Received: by 10.204.128.198 with SMTP id l6mr2252012bks.19.1308579970346;
	Mon, 20 Jun 2011 07:26:10 -0700 (PDT)
Received: from localhost (176.119.broadband10.iol.cz. [90.177.119.176])
	by mx.google.com with ESMTPS id a28sm1139319fak.1.2011.06.20.07.26.08
	(version=TLSv1/SSLv3 cipher=OTHER);
	Mon, 20 Jun 2011 07:26:09 -0700 (PDT)
From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#8897: `completion--insert-strings' clobbers user-added text
	properties
In-Reply-To: <jwvwrggk3m3.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Mon, 20 Jun 2011 10:01:22 -0400")
References: <8739j5bs01.fsf@HIDDEN> <jwvd3i9mcbm.fsf-monnier+emacs@HIDDEN>
	<87y60x9b8y.fsf@HIDDEN> <jwvwrggk3m3.fsf-monnier+emacs@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Date: Mon, 20 Jun 2011 16:22:02 +0200
Message-ID: <87pqm8a8hh.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.6 (---)
X-Debbugs-Envelope-To: 8897
Cc: 8897 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.6 (---)

Stefan Monnier <monnier@HIDDEN> writes:

>> #+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).

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.

>> With my patch I haven't noticed any problems you mention -- clicking
>> or RET on the completion itself selects it, clicking or RET on the
>> annotation displays further details, the button face is preserved.
>
> I guess click&RET work OK because they're locally overridden, but if you
> run M-x choose-completion while on the button or if you hit `left' or
> `right' to skip from one completion to the next, you might see some
> problem (although not with the code quoted above which should not
> suffer from any of the problems discussed in this thread, AFAICT).

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.

  =C5=A0t=C4=9Bp=C3=A1n




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8897; Package emacs. Full text available.

Message received at 8897 <at> debbugs.gnu.org:


Received: (at 8897) by debbugs.gnu.org; 20 Jun 2011 14:01:36 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 20 10:01:36 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QYf2l-0007CI-Kg
	for submit <at> debbugs.gnu.org; Mon, 20 Jun 2011 10:01:35 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.183]
	helo=ironport2-out.pppoe.ca)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QYf2j-0007C5-CK
	for 8897 <at> debbugs.gnu.org; Mon, 20 Jun 2011 10:01:34 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av0EAJRS/01FpYrD/2dsb2JhbABTplx4iHO+e4YqBJ1ZhCI
X-IronPort-AV: E=Sophos;i="4.65,394,1304308800"; d="scan'208";a="116667414"
Received: from 69-165-138-195.dsl.teksavvy.com (HELO pastel.home)
	([69.165.138.195])
	by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA;
	20 Jun 2011 10:01:22 -0400
Received: by pastel.home (Postfix, from userid 20848)
	id 4F00759011; Mon, 20 Jun 2011 10:01:22 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
Subject: Re: bug#8897: `completion--insert-strings' clobbers user-added text
	properties
Message-ID: <jwvwrggk3m3.fsf-monnier+emacs@HIDDEN>
References: <8739j5bs01.fsf@HIDDEN> <jwvd3i9mcbm.fsf-monnier+emacs@HIDDEN>
	<87y60x9b8y.fsf@HIDDEN>
Date: Mon, 20 Jun 2011 10:01:22 -0400
In-Reply-To: <87y60x9b8y.fsf@HIDDEN> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?=
	=?utf-8?B?ZWMiJ3M=?= message of "Mon, 20 Jun 2011 10:07:41 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 8897
Cc: 8897 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.1 (--)

>>> In my particular case I define annotations as buttons (which display
>>> even more detail about a completion value upon activation), so a visual
>>> indication of clickability is very important for me.
>> Currently, the completion-list-mode uses the `mouse-face' text-property
>> to determine what is a completion item and what i something else (blank
>> space, annotation, you name it).  So as it stands, any mouse-face you'd
>> add to an annotation would confuse completion-list-mode into thinking it
>> is a completion item.
>> Maybe you could try to use the `category' text-property instead.

> Well I do use the `category' property, but the button functions seem to
> set up the button face automatically, which is then clobbered by
> `completion--insert-strings' (which is the problem). Here's how I set up
> an annotation, `n' being the number of a pull request as a string (i.e.,
> the completion value itself):

> #+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.

> With my patch I haven't noticed any problems you mention -- clicking
> or RET on the completion itself selects it, clicking or RET on the
> annotation displays further details, the button face is preserved.

I guess click&RET work OK because they're locally overridden, but if you
run M-x choose-completion while on the button or if you hit `left' or
`right' to skip from one completion to the next, you might see some
problem (although not with the code quoted above which should not
suffer from any of the problems discussed in this thread, AFAICT).


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8897; Package emacs. Full text available.

Message received at 8897 <at> debbugs.gnu.org:


Received: (at 8897) by debbugs.gnu.org; 20 Jun 2011 08:11:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Jun 20 04:11:57 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QYZaO-0005yA-PP
	for submit <at> debbugs.gnu.org; Mon, 20 Jun 2011 04:11:57 -0400
Received: from mail-fx0-f44.google.com ([209.85.161.44])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stepnem@HIDDEN>) id 1QYZaN-0005xw-Bc
	for 8897 <at> debbugs.gnu.org; Mon, 20 Jun 2011 04:11:56 -0400
Received: by fxm15 with SMTP id 15so1001913fxm.3
	for <8897 <at> debbugs.gnu.org>; Mon, 20 Jun 2011 01:11:49 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:cc:subject:in-reply-to:references
	:user-agent:date:message-id:mime-version:content-type
	:content-transfer-encoding;
	bh=PX8+uNJWTlNW8mFP7iKmem2oj3iwc7uEeyV5nZQig/s=;
	b=etAwLlBphN3YCIS5dyQcuLefQWY0jHkIqn2umVwQjWlWnTRgz+MF4Oa/D0EGXzzeim
	s1QYK3aPX+U90iLJqut2bT8pyNXXqKSYuY5iDxq7AXts8BjeYWtI95AU3xUWj1jXMjhu
	AGfE5/OxfIBcjkYyGYELxKtTkRLVGlpQR4IJQ=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:cc:subject:in-reply-to:references:user-agent:date
	:message-id:mime-version:content-type:content-transfer-encoding;
	b=rbeWV1akSIYPVdRNzVSOHjuM/DdN4j1R3AK0k7gncURaa4Eu4Vlro3Gun3oSw7INjC
	7i83FC7Y1qg71tgPMLUBad/xU9jiZ7hb6q0znMVn3HI530uoysIJeq+ZUZ9vjL78I6Sj
	TCzXOpoGlqgeVFBqpyFCCDRVsHEMHM+G90XrM=
Received: by 10.223.16.136 with SMTP id o8mr4780247faa.21.1308557509286;
	Mon, 20 Jun 2011 01:11:49 -0700 (PDT)
Received: from localhost (176.119.broadband10.iol.cz [90.177.119.176])
	by mx.google.com with ESMTPS id m5sm2045399fai.25.2011.06.20.01.11.47
	(version=TLSv1/SSLv3 cipher=OTHER);
	Mon, 20 Jun 2011 01:11:47 -0700 (PDT)
From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
To: Stefan Monnier <monnier@HIDDEN>
Subject: Re: bug#8897: `completion--insert-strings' clobbers user-added text
	properties
In-Reply-To: <jwvd3i9mcbm.fsf-monnier+emacs@HIDDEN> (Stefan Monnier's message
	of "Sun, 19 Jun 2011 23:08:55 -0400")
References: <8739j5bs01.fsf@HIDDEN> <jwvd3i9mcbm.fsf-monnier+emacs@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
Date: Mon, 20 Jun 2011 10:07:41 +0200
Message-ID: <87y60x9b8y.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: -3.6 (---)
X-Debbugs-Envelope-To: 8897
Cc: 8897 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -3.6 (---)

Stefan Monnier <monnier@HIDDEN> writes:

>> In my particular case I define annotations as buttons (which display
>> even more detail about a completion value upon activation), so a visual
>> indication of clickability is very important for me.
>
> Currently, the completion-list-mode uses the `mouse-face' text-property
> to determine what is a completion item and what i something else (blank
> space, annotation, you name it).  So as it stands, any mouse-face you'd
> add to an annotation would confuse completion-list-mode into thinking it
> is a completion item.
>
> Maybe you could try to use the `category' text-property instead.

Well I do use the `category' property, but the button functions seem to
set up the button face automatically, which is then clobbered by
`completion--insert-strings' (which is the problem). Here's how I set up
an annotation, `n' being the number of a pull request as a string (i.e.,
the completion value itself):

#+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

With my patch I haven't noticed any problems you mention -- clicking
or RET on the completion itself selects it, clicking or RET on the
annotation displays further details, the button face is preserved.

  =C5=A0t=C4=9Bp=C3=A1n




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8897; Package emacs. Full text available.

Message received at 8897 <at> debbugs.gnu.org:


Received: (at 8897) by debbugs.gnu.org; 20 Jun 2011 03:09:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 19 23:09:05 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QYUrI-0000s5-8J
	for submit <at> debbugs.gnu.org; Sun, 19 Jun 2011 23:09:04 -0400
Received: from ironport2-out.teksavvy.com ([206.248.154.181]
	helo=ironport2-out.pppoe.ca)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <monnier@HIDDEN>) id 1QYUrG-0000rb-5F
	for 8897 <at> debbugs.gnu.org; Sun, 19 Jun 2011 23:09:02 -0400
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: Av0EAPm4/k1FpYrD/2dsb2JhbABSplp4iHO9WYYqBJ1ZhCI
X-IronPort-AV: E=Sophos;i="4.65,391,1304308800"; d="scan'208";a="116644878"
Received: from 69-165-138-195.dsl.teksavvy.com (HELO pastel.home)
	([69.165.138.195])
	by ironport2-out.pppoe.ca with ESMTP/TLS/ADH-AES256-SHA;
	19 Jun 2011 23:08:56 -0400
Received: by pastel.home (Postfix, from userid 20848)
	id 79BEA58B27; Sun, 19 Jun 2011 23:08:55 -0400 (EDT)
From: Stefan Monnier <monnier@HIDDEN>
To: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
Subject: Re: bug#8897: `completion--insert-strings' clobbers user-added text
	properties
Message-ID: <jwvd3i9mcbm.fsf-monnier+emacs@HIDDEN>
References: <8739j5bs01.fsf@HIDDEN>
Date: Sun, 19 Jun 2011 23:08:55 -0400
In-Reply-To: <8739j5bs01.fsf@HIDDEN> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?=
	=?utf-8?B?ZWMiJ3M=?= message of "Sun, 19 Jun 2011 20:22:54 +0200")
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: -2.1 (--)
X-Debbugs-Envelope-To: 8897
Cc: 8897 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -2.1 (--)

> In my particular case I define annotations as buttons (which display
> even more detail about a completion value upon activation), so a visual
> indication of clickability is very important for me.

Currently, the completion-list-mode uses the `mouse-face' text-property
to determine what is a completion item and what i something else (blank
space, annotation, you name it).  So as it stands, any mouse-face you'd
add to an annotation would confuse completion-list-mode into thinking it
is a completion item.

Maybe you could try to use the `category' text-property instead.


        Stefan




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8897; Package emacs. Full text available.

Message received at 8897 <at> debbugs.gnu.org:


Received: (at 8897) by debbugs.gnu.org; 19 Jun 2011 18:34:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 19 14:34:40 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QYMpU-0005PH-I0
	for submit <at> debbugs.gnu.org; Sun, 19 Jun 2011 14:34:40 -0400
Received: from fencepost.gnu.org ([140.186.70.10])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <rgm@HIDDEN>) id 1QYMpT-0005P3-AY
	for 8897 <at> debbugs.gnu.org; Sun, 19 Jun 2011 14:34:39 -0400
Received: from localhost ([127.0.0.1]:46774)
	by fencepost.gnu.org with esmtp (Exim 4.71)
	(envelope-from <rgm@HIDDEN>)
	id 1QYMpL-0008BB-Uu; Sun, 19 Jun 2011 14:34:32 -0400
From: Glenn Morris <rgm@HIDDEN>
To: stepnem@HIDDEN
Subject: Re: bug#8897: `completion--insert-strings' clobbers user-added text
	properties
References: <8739j5bs01.fsf@HIDDEN>
X-Spook: terrorism Glock Cocaine jihad Majic encryption MDA Steve
X-Ran: ,AZCJfQ'5a1"Rz.pLcl=9YX'mDm3>`#ddTPhtT$;Cp&Q2ndb{{*7(LF|Fyqn]92l4ZN<\a
X-Hue: white
X-Debbugs-No-Ack: yes
X-Attribution: GM
Date: Sun, 19 Jun 2011 14:34:31 -0400
In-Reply-To: <8739j5bs01.fsf@HIDDEN> (=?utf-8?B?IsWgdMSbcMOhbiBOxJtt?=
	=?utf-8?B?ZWMiJ3M=?= message of "Sun, 19 Jun 2011 20:22:54 +0200")
Message-ID: <8i39j53c20.fsf@HIDDEN>
User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Spam-Score: -6.3 (------)
X-Debbugs-Envelope-To: 8897
Cc: 8897 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -6.3 (------)


> I wonder if something like the patch below, which fixes the problem for
> me, could be applied?

We cannot apply any (more) patches from you because you don't want to
complete a copyright assignment. That's your prerogative of course, but
given that, it is best if you do not send patches when you report issues.




Information forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8897; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Jun 2011 18:27:15 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jun 19 14:27:15 2011
Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1QYMiJ-0004SA-4t
	for submit <at> debbugs.gnu.org; Sun, 19 Jun 2011 14:27:15 -0400
Received: from eggs.gnu.org ([140.186.70.92])
	by debbugs.gnu.org with esmtp (Exim 4.69)
	(envelope-from <stepnem@HIDDEN>) id 1QYMiG-0004Ry-Fp
	for submit <at> debbugs.gnu.org; Sun, 19 Jun 2011 14:27:13 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QYMiA-0001ef-5b
	for submit <at> debbugs.gnu.org; Sun, 19 Jun 2011 14:27:07 -0400
X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,
	RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST,T_DKIM_INVALID autolearn=unavailable
	version=3.3.1
Received: from lists.gnu.org ([140.186.70.17]:54243)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QYMi9-0001eb-UG
	for submit <at> debbugs.gnu.org; Sun, 19 Jun 2011 14:27:06 -0400
Received: from eggs.gnu.org ([140.186.70.92]:41074)
	by lists.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QYMi8-0001yS-KR
	for bug-gnu-emacs@HIDDEN; Sun, 19 Jun 2011 14:27:05 -0400
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QYMi7-0001cP-2H
	for bug-gnu-emacs@HIDDEN; Sun, 19 Jun 2011 14:27:04 -0400
Received: from mail-fx0-f52.google.com ([209.85.161.52]:32888)
	by eggs.gnu.org with esmtp (Exim 4.71)
	(envelope-from <stepnem@HIDDEN>) id 1QYMi6-0001cL-PP
	for bug-gnu-emacs@HIDDEN; Sun, 19 Jun 2011 14:27:02 -0400
Received: by fxm6 with SMTP id 6so1640199fxm.39
	for <bug-gnu-emacs@HIDDEN>; Sun, 19 Jun 2011 11:27:01 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;
	h=domainkey-signature:from:to:subject:date:message-id:mime-version
	:content-type; bh=bjoY29tIR+b9qdrODb+MyzqR5MSh5JOYSdpApNXWLQ8=;
	b=oEGiOqSxgBN+DRg44MmqaU2hFbgY0GwXEfufhJQa35FZJP480HvCvwU5WUu/YosOV6
	ISCu9geee4XdkuOh3S3iBKaJAkHi4WSf5um+UmOBsGjAVU2Al6mb/WwN9EGTxwt6nBCe
	nBcfDPcfvMJPfHlVQG2yVmtr7/Mspoy5tcTuM=
DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;
	h=from:to:subject:date:message-id:mime-version:content-type;
	b=fevg/tQv9TCKVqQoD7beXUr90E6f4PVtx6pusoRiQdmSIa8wqht8+5aLpuKzyEYiy7
	1KqOBAitg/6YkUN9zagkXLmKfn34UZ8ejFu89uEMn0pL4QWlR7Eu01YZwya8YfyvzhVV
	R87jfsHZybW1rK8s4sr3HzwSZ2M2tkZP05Qbs=
Received: by 10.223.78.140 with SMTP id l12mr4924964fak.147.1308508021318;
	Sun, 19 Jun 2011 11:27:01 -0700 (PDT)
Received: from localhost (176.119.broadband10.iol.cz [90.177.119.176])
	by mx.google.com with ESMTPS id r10sm2379949fah.26.2011.06.19.11.26.59
	(version=TLSv1/SSLv3 cipher=OTHER);
	Sun, 19 Jun 2011 11:27:00 -0700 (PDT)
From: =?utf-8?B?xaB0xJtww6FuIE7Em21lYw==?= <stepnem@HIDDEN>
To: bug-gnu-emacs <bug-gnu-emacs@HIDDEN>
Subject: `completion--insert-strings' clobbers user-added text properties
Date: Sun, 19 Jun 2011 20:22:54 +0200
Message-ID: <8739j5bs01.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2)
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3)
X-Received-From: 140.186.70.17
X-Spam-Score: -4.7 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.11
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/pipermail/debbugs-submit>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>,
	<mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Sender: debbugs-submit-bounces <at> debbugs.gnu.org
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
X-Spam-Score: -4.7 (----)

Tags: patch

It is possible to bind `completion-annotate-function' to add custom
annotations, which is great. Unfortunately, the `face' and `mouse-face'
text properties added by such a function are then unconditionally
overwritten by `completion--insert-strings'.

In my particular case I define annotations as buttons (which display
even more detail about a completion value upon activation), so a visual
indication of clickability is very important for me.

I wonder if something like the patch below, which fixes the problem for
me, could be applied?

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index 284cbdc..11534e6 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1003,9 +1003,12 @@ (defun completion--insert-strings (strings)
                                    'mouse-face 'highlight)
               (put-text-property (point) (progn (insert (car str)) (point))
                                  'mouse-face 'highlight)
-              (add-text-properties (point) (progn (insert (cadr str)) (point))
-                                   '(mouse-face nil
-						face completions-annotations)))
+              (let ((annotation (cadr str)))
+                (if (text-properties-at 1 annotation)
+                    (insert annotation)
+                  (add-text-properties (point) (progn (insert annotation) (point))
+                                       '(mouse-face nil
+                                                    face completions-annotations)))))
 	    (cond
 	     ((eq completions-format 'vertical)
 	      ;; Vertical format




Acknowledgement sent to Štěpán Němec <stepnem@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to owner <at> debbugs.gnu.org, bug-gnu-emacs@HIDDEN:
bug#8897; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Fri, 31 Oct 2014 17:00:04 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.