unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* button face vs font-lock
@ 2008-01-27 12:13 Thien-Thi Nguyen
  0 siblings, 0 replies; 2+ messages in thread
From: Thien-Thi Nguyen @ 2008-01-27 12:13 UTC (permalink / raw)
  To: gnu-emacs-help

Greetings,

I'm trying to implement a simple toggle button, using:

 (define-button-type 'toggle
   'mouse-face nil
   'follow-link t
   'help-echo nil
   'active nil
   'face 'button
   'action (lambda (button)
             (let ((now (not (button-get button 'active))))
               (button-put button 'active now)
               (button-put button 'face (if now
                                            font-lock-keyword-face
                                          'button))
               (message "%s %s" (button-label button) now))))
 
 (insert-text-button "abc" :type 'toggle)

This works fine when font-lock is off (M-x font-lock-mode RET),
but when i enable font-lock, the button refuses to change face,
although the toggling is still evidenced in the echo area.

What do i need to do get font lock to leave dynamic button
face changing alone?

thi

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: button face vs font-lock
       [not found] <mailman.6603.1201438685.18990.help-gnu-emacs@gnu.org>
@ 2008-01-27 14:05 ` Johan Bockgård
  0 siblings, 0 replies; 2+ messages in thread
From: Johan Bockgård @ 2008-01-27 14:05 UTC (permalink / raw)
  To: help-gnu-emacs

Thien-Thi Nguyen <ttn@gnuvola.org> writes:

> What do i need to do get font lock to leave dynamic button face
> changing alone?

Easiest is probably to use an overlay-based button (`make-button').

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-01-27 14:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-27 12:13 button face vs font-lock Thien-Thi Nguyen
     [not found] <mailman.6603.1201438685.18990.help-gnu-emacs@gnu.org>
2008-01-27 14:05 ` Johan Bockgård

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).