From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Pierre Lorenzon Newsgroups: gmane.emacs.help Subject: Using widgets and timers simultaneously Date: Mon, 30 Apr 2007 22:21:13 +0200 (CEST) Message-ID: <20070430.222113.74720370.pollock.nageoire@wanadoo.fr> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1177964538 15325 80.91.229.12 (30 Apr 2007 20:22:18 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 30 Apr 2007 20:22:18 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Mon Apr 30 22:22:16 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1HicNy-0003Tf-Sv for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Apr 2007 22:22:15 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HicUC-0006Lm-83 for geh-help-gnu-emacs@m.gmane.org; Mon, 30 Apr 2007 16:28:40 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1HicTv-0006K0-3p for help-gnu-emacs@gnu.org; Mon, 30 Apr 2007 16:28:23 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1HicTt-0006EB-A3 for help-gnu-emacs@gnu.org; Mon, 30 Apr 2007 16:28:22 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1HicTs-0006DC-SB for help-gnu-emacs@gnu.org; Mon, 30 Apr 2007 16:28:20 -0400 Original-Received: from smtp20.orange.fr ([193.252.22.31]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1HicNe-0007On-La for help-gnu-emacs@gnu.org; Mon, 30 Apr 2007 16:21:54 -0400 Original-Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf2019.orange.fr (SMTP Server) with ESMTP id D262B1C00091 for ; Mon, 30 Apr 2007 22:21:52 +0200 (CEST) Original-Received: from localhost (APuteaux-154-1-26-151.w83-199.abo.wanadoo.fr [83.199.81.151]) by mwinf2019.orange.fr (SMTP Server) with ESMTP id 9E9201C0008D for ; Mon, 30 Apr 2007 22:21:52 +0200 (CEST) X-ME-UUID: 20070430202152649.9E9201C0008D@mwinf2019.orange.fr X-detected-kernel: Linux 2.4-2.6 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:43418 Archived-At: 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