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

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

Re: Problem in xterm-mouse-event in longrunning emacs process


From: Stefan Monnier
Subject: Re: Problem in xterm-mouse-event in longrunning emacs process
Date: Thu, 24 May 2007 12:50:29 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux)

> Interpreting this is milliseconds, it follows that after 74 hours, 33
> minutes and 55 seconds I will start getting the error :(

Hmm.. the code needs the integer to wrap-around, but truncate refuses to
do that.

Does the patch below work?


        Stefan


--- xt-mouse.el 16 mai 2007 11:59:29 -0400      1.40
+++ xt-mouse.el 24 mai 2007 12:50:14 -0400      
@@ -126,6 +126,14 @@
         (+ c #x8000000 128)
       c)))
 
+(defun xterm-mouse-truncate (f)
+  "Truncate with wrap-around."
+  ;; We assume there's no more than 1000000 wraparounds.
+  (let* ((maxwrap 1000000)
+         (dbig (truncate (/ f maxwrap)))
+         (fdiff (- f (* 1.0 maxwrap dbig))))
+    (+ (truncate fdiff) (* maxwrap dbig))))
+
 (defun xterm-mouse-event ()
   "Convert XTerm mouse event to Emacs mouse event."
   (let* ((type (- (xterm-mouse-event-read) #o40))
@@ -133,7 +141,7 @@
         (y (- (xterm-mouse-event-read) #o40 1))
         ;; Emulate timestamp information.  This is accurate enough
         ;; for default value of mouse-1-click-follows-link (450msec).
-        (timestamp (truncate
+        (timestamp (xterm-mouse-truncate
                     (* 1000
                        (- (float-time)
                           (or xt-mouse-epoch




reply via email to

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