From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Damien Cassou Newsgroups: gmane.emacs.bugs Subject: bug#12817: 24.2; The button library does not work on the header line Date: Thu, 6 Dec 2012 08:38:01 +0100 Message-ID: References: <87ehj4mdxo.fsf@bernoul.li> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=20cf3079b744c9bf8104d02a2d86 X-Trace: ger.gmane.org 1354779540 7745 80.91.229.3 (6 Dec 2012 07:39:00 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 6 Dec 2012 07:39:00 +0000 (UTC) Cc: 12817@debbugs.gnu.org To: Jonas Bernoulli Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 06 08:39:13 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TgW36-0004TS-Lx for geb-bug-gnu-emacs@m.gmane.org; Thu, 06 Dec 2012 08:39:12 +0100 Original-Received: from localhost ([::1]:55197 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgW2u-0007qy-Mc for geb-bug-gnu-emacs@m.gmane.org; Thu, 06 Dec 2012 02:39:00 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:38276) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgW2m-0007pR-DS for bug-gnu-emacs@gnu.org; Thu, 06 Dec 2012 02:38:58 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TgW2k-000199-Vz for bug-gnu-emacs@gnu.org; Thu, 06 Dec 2012 02:38:52 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:45539) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TgW2k-000195-SH for bug-gnu-emacs@gnu.org; Thu, 06 Dec 2012 02:38:50 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TgW2v-0005Ry-VD for bug-gnu-emacs@gnu.org; Thu, 06 Dec 2012 02:39:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Damien Cassou Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 06 Dec 2012 07:39:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12817 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 12817-submit@debbugs.gnu.org id=B12817.135477951420909 (code B ref 12817); Thu, 06 Dec 2012 07:39:01 +0000 Original-Received: (at 12817) by debbugs.gnu.org; 6 Dec 2012 07:38:34 +0000 Original-Received: from localhost ([127.0.0.1]:55790 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TgW2R-0005R6-GL for submit@debbugs.gnu.org; Thu, 06 Dec 2012 02:38:33 -0500 Original-Received: from mail-vc0-f172.google.com ([209.85.220.172]:59334) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TgW2A-0005QQ-8l for 12817@debbugs.gnu.org; Thu, 06 Dec 2012 02:38:26 -0500 Original-Received: by mail-vc0-f172.google.com with SMTP id fw7so7184955vcb.3 for <12817@debbugs.gnu.org>; Wed, 05 Dec 2012 23:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=AvkP4DFogOOHcFqEEkVVLU+UPbkYGCl87AjpUNkzyiE=; b=D53m6Iyd3k7dNXqIQ8NZlb1gf8/yuLPzBqj6Ee8+Mrj0rt4vYVIHeastXX5AlCwp4A TL+o+pATRD5+jzjfYTwOLMLh3vijdyL/3TbTOjjvLJ8VmJzwi3MssPtaB5PpTxR2YWFj NLkT5SfhGh/OTaSjKW//PTs7POx6pOJlPIRgyftTvA12i3ubGWECTp2tK+aHd95Ru5TX pWCSpU9/rlA8dAbWOVANKwU3eLHqXOKkbHFm69/gWlcoE+Rd4h8fEDU3LxJq2Y+FRfQM kKvT4NqLRmipmr85BR1G2d6fdgSTQmlnELwqStmR8KdxlbrUFXCMwMDdZ9mWIS+H7Uho 3pEA== Original-Received: by 10.52.28.129 with SMTP id b1mr304509vdh.79.1354779482242; Wed, 05 Dec 2012 23:38:02 -0800 (PST) Original-Received: by 10.58.143.51 with HTTP; Wed, 5 Dec 2012 23:38:01 -0800 (PST) Original-Received: by 10.58.143.51 with HTTP; Wed, 5 Dec 2012 23:38:01 -0800 (PST) In-Reply-To: <87ehj4mdxo.fsf@bernoul.li> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:68014 Archived-At: --20cf3079b744c9bf8104d02a2d86 Content-Type: text/plain; charset=ISO-8859-1 Thank you very much Jonas Damien Cassou http://damiencassou.seasidehosting.st On Dec 5, 2012 9:39 PM, "Jonas Bernoulli" wrote: > The attached patch allows inserting buttons into the header-line as well > as the mode-line. I haven't tested it much but it appears to work. > > As you suggested it doesn't use a function such as > `header-button-format'. Instead `make-text-button' was changed to > return a useful value when BEG is a string: the propertized string. > > ,---- > | (setq header-line-format > | (make-text-button "test" nil > | 'action (lambda (button) > | (message "Button: %s" button)))) > `---- > > The above is enough now to insert a button in the header-line or > mode-line. No need for an intermediate variable to hold the string. > Additionally the following changes are needed so that clicking the > button actually does something. > > Add an additional kind of "button object" that is used internally and > passed to the button action function: "area buttons" (analogously to > `posn-area'). Normally these have the form (STRING . STRING-POS), where > STRING is the propertized string and STRING-POS is list of the form > returned by `event-start'. STRING-POS might be useful in actions but > isn't used internally. Area button objects can also be just a string. > > [mode-line mouse-2] and [header-line mouse-2] are bound to push-button > just like [mouse-2]. [follow-link] is not actually used at all. (I > think it was used instead of [mouse-2] in the past, but I might be > wrong). > > I don't know whether binding these events might cause problems for > regular buttons, but it does not appear to be the case. > > (Maybe using follow-link instead and extending it to work in the > header-line and mode-line would be better; but I know to little about > that. The little I do know tells me doing so would probably not be > worth the effort.) > > `push-button', `button-get', `button-put', `button-label' are taught to > deal with area buttons. Using `button-start', `button-end' and > `button-at' with an area button causes an error. Of the "button > creating functions" only `make-text-button' is useful for area buttons. > `[next|previous|forward|backward]-button' also cannot be used. > > The patch is against 24.3.50 from a few days ago but if necessary I can > redo it against a different version. > > --20cf3079b744c9bf8104d02a2d86 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

Thank you very much Jonas

Damien Cassou
http://damiencassou.seasi= dehosting.st

On Dec 5, 2012 9:39 PM, "Jonas Bernoulli&qu= ot; <jonas@bernoul.li> wrote:=
The attached patch allows inserting buttons into the header-line as well as the mode-line. =A0I haven't tested it much but it appears to work.
As you suggested it doesn't use a function such as
`header-button-format'. =A0Instead `make-text-button' was changed t= o
return a useful value when BEG is a string: the propertized string.

,----
| (setq header-line-format
| =A0 =A0 =A0 (make-text-button "test" nil
| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 'action (lambda (butt= on)
| =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (mess= age "Button: %s" button))))
`----

The above is enough now to insert a button in the header-line or
mode-line. =A0No need for an intermediate variable to hold the string.
Additionally the following changes are needed so that clicking the
button actually does something.

Add an additional kind of "button object" that is used internally= and
passed to the button action function: "area buttons" (analogously= to
`posn-area'). =A0Normally these have the form (STRING . STRING-POS), wh= ere
STRING is the propertized string and STRING-POS is list of the form
returned by `event-start'. =A0STRING-POS might be useful in actions but=
isn't used internally. =A0Area button objects can also be just a string= .

[mode-line mouse-2] and [header-line mouse-2] are bound to push-button
just like [mouse-2]. =A0[follow-link] is not actually used at all. =A0(I think it was used instead of [mouse-2] in the past, but I might be
wrong).

I don't know whether binding these events might cause problems for
regular buttons, but it does not appear to be the case.

(Maybe using follow-link instead and extending it to work in the
header-line and mode-line would be better; but I know to little about
that. =A0The little I do know tells me doing so would probably not be
worth the effort.)

`push-button', `button-get', `button-put', `button-label' a= re taught to
deal with area buttons. =A0Using `button-start', `button-end' and `button-at' with an area button causes an error. =A0Of the "button=
creating functions" only `make-text-button' is useful for area but= tons.
`[next|previous|forward|backward]-button' also cannot be used.

The patch is against 24.3.50 from a few days ago but if necessary I can
redo it against a different version.

--20cf3079b744c9bf8104d02a2d86--