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

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

bug#12817: 24.2; The button library does not work on the header line


From: Jonas Bernoulli
Subject: bug#12817: 24.2; The button library does not work on the header line
Date: Wed, 05 Dec 2012 21:39:15 +0100
User-agent: mu4e 0.9.9.5-dev4; emacs 24.3.50.1

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.

Attachment: 0001-area-buttons.patch
Description: Text Data


reply via email to

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