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

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

Re: Using widgets and timers simultaneously


From: Pierre Lorenzon
Subject: Re: Using widgets and timers simultaneously
Date: Tue, 01 May 2007 15:30:29 +0200 (CEST)

Hi

From: martin rudalics <address@hidden>
Subject: Re: Using widgets and timers simultaneously
Date: Tue, 01 May 2007 14:14:59 +0200

>  > (defun refresh ()
>  >   (let ((pos (point)))
>  >     (widget-delete my-widget)
>  >     (setq my-widget (widget-create 'timed))
>  >     (goto-char pos))
>  >   (widget-setup))
> 
> It occurs to me that in `refresh' you set up `my-widget' in the buffer
> that's current at that time, hence your widget might eventually appear
> in all your buffers.

  Indeed it is a bad "collateral" effect that might easily be
  improved but this not the heart of the problem !


> 
>  > Indeed it works i.e. time is redisplayed every 5 seconds. But
>  > when I try to move the cursor in the buffer the behavior might
>  > become some how erratic ! In fact especially after using up and
>  > down arrow keys, the widget is no longer well displayed. The
>  > formating characters appear "%{" "%[" or things like that just
>  > as if the delete-backward-char method in the creating method
>  > would not have any effect.
> 
> I recall that widgets may get screwed up when text is replaced at text
> boundaries.  In principle you should make sure yourself that mutable
> text is surrounded by immutable one.

  I suppose the point is here but I don't really understand !
  Can you give me more details ? 

  Indeed I implemented the refresh method slightly differently
  :

  (defun refresh ()
  (widget-value-set my-widget (current-time-string)))

  It avoids the setq my-widget mentioned above and which was
  not really good as you observed. But since the
  widget-defaul-value-set still require the
  widget-default-create method the problem with the
  delete-backward-char which is not executed is still there !

Bests

Pierre





reply via email to

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