From: Pierre Lorenzon <pollock.nageoire@wanadoo.fr>
To: help-gnu-emacs@gnu.org
Subject: Using widgets and timers simultaneously
Date: Mon, 30 Apr 2007 22:21:13 +0200 (CEST) [thread overview]
Message-ID: <20070430.222113.74720370.pollock.nageoire@wanadoo.fr> (raw)
Hi all,
I.d like to use widgets and timers in conjunction. What I'd
like to be able to do is to set up a timer which will refresh a
certain widget periodically. Here is the code I wrote but
certainly I'd like to do more sophisticated tasks than simply
displaying the time !
--- Code ---
(defvar my-widget nil)
(defvar my-timer)
(define-widget
'timed
'string
""
:value-to-internal
(lambda (widget value) (current-time-string)))
(defun refresh ()
(let ((pos (point)))
(widget-delete my-widget)
(setq my-widget (widget-create 'timed))
(goto-char pos))
(widget-setup))
(switch-to-buffer (get-buffer-create "*Clock*"))
(setq my-widget (widget-create 'timed))
(use-local-map widget-keymap)
(widget-setup)
(setq my-timer (run-at-time nil 5 'refresh))
--- End Code ---
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.
Can somebody explain me why ; and give me an indication to solve
this question ? You certainly might say that widgets are not
adapted to display parts of a buffer that must be periodically
refreshed and that I should use something like overlays. Sure
but it would be much more convenient for me if I could use
widgets and moreover widgets displaying is more or less based
on overlays.
Notice that if I replace the (let ((pos ...)) form in the
refresh method by a save-excursion the cursor always goes at
the beginning of the buffer as if all marks were killed by the
widget displayin mechanism.
Bests
Pierre
next reply other threads:[~2007-04-30 20:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-04-30 20:21 Pierre Lorenzon [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-05-01 12:14 Using widgets and timers simultaneously martin rudalics
2007-05-01 13:30 ` Pierre Lorenzon
2007-05-02 8:36 ` martin rudalics
2007-05-08 13:11 ` Pierre Lorenzon
[not found] <mailman.12.1177964905.32220.help-gnu-emacs@gnu.org>
2007-05-01 16:26 ` Johan Bockgård
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070430.222113.74720370.pollock.nageoire@wanadoo.fr \
--to=pollock.nageoire@wanadoo.fr \
--cc=help-gnu-emacs@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).