emacs-devel
[Top][All Lists]
Advanced

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

Re: storing mouse-movement events in recent-keys and keyboard macros


From: Kim F. Storm
Subject: Re: storing mouse-movement events in recent-keys and keyboard macros
Date: 07 Dec 2001 22:37:31 +0100
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1

address@hidden (Kim F. Storm) writes:

> I'm working on a small patch which will store only the first and the
> last in a series of mouse movements (in the same window) in the
> list, i.e. it would tell you where the move started, where it ended,
> but not how it got there :-)

The following patch does this - as well as avoid recording mouse
movements in keyboard macros.  

Index: keyboard.c
===================================================================
RCS file: /cvs/emacs/src/keyboard.c,v
retrieving revision 1.642
diff -u -r1.642 keyboard.c
--- keyboard.c  2001/12/05 02:51:12     1.642
+++ keyboard.c  2001/12/07 19:47:27
@@ -2982,15 +2982,19 @@
 record_char (c)
      Lisp_Object c;
 {
-  /* Don't record `help-echo' in recent_keys unless it shows some help
-     message, and a different help than the previoiusly recorded
-     event.  */
+  int recorded = 0;
+
   if (CONSP (c) && EQ (XCAR (c), Qhelp_echo))
     {
+      /* Don't record `help-echo' in recent_keys unless it shows some help
+        message, and a different help than the previoiusly recorded
+        event.  */
       Lisp_Object help;
 
       help = Fcar (Fcdr (XCDR (c)));
-      if (STRINGP (help))
+      if (!STRINGP (help))
+       recorded = 1;
+      else
        {
          int last_idx;
          Lisp_Object last_c, last_help;
@@ -3000,25 +3004,57 @@
            last_idx = NUM_RECENT_KEYS - 1;
          last_c = AREF (recent_keys, last_idx);
          
-         if (!CONSP (last_c)
-             || !EQ (XCAR (last_c), Qhelp_echo)
-             || (last_help = Fcar (Fcdr (XCDR (last_c))),
-                 !EQ (last_help, help)))
+         if (CONSP (last_c)
+             && EQ (XCAR (last_c), Qhelp_echo)
+             && (last_help = Fcar (Fcdr (XCDR (last_c))),
+                 EQ (last_help, help)))
+           recorded = 1;
+       }
+    }
+  else if (CONSP (c) && EQ (XCAR (c), Qmouse_movement))
+    {
+      /* Only record one pair of `mouse-movement' on a window in recent_keys.
+        So additional mouse movement events replace the last element.  */
+      Lisp_Object last_c, last_window, window;
+      int last_idx;
+
+      window = Fcar (Fcar (XCDR (c)));
+      if ((last_idx = recent_keys_index - 1) < 0)
+       last_idx = NUM_RECENT_KEYS - 1;
+      last_c = AREF (recent_keys, last_idx);
+
+      if (CONSP (last_c)
+         && EQ (XCAR (last_c), Qmouse_movement)
+         && (last_window = Fcar (Fcar (XCDR (last_c))),
+             EQ (last_window, window)))
            {
-             total_keys++;
-             ASET (recent_keys, recent_keys_index, c);
-             if (++recent_keys_index >= NUM_RECENT_KEYS)
-               recent_keys_index = 0;
+             int last2_idx;
+             if ((last2_idx = last_idx - 1) < 0)
+               last2_idx = NUM_RECENT_KEYS - 1;
+             last_c = AREF (recent_keys, last2_idx);
+
+             if (CONSP (last_c)
+                 && EQ (XCAR (last_c), Qmouse_movement)
+                 && (last_window = Fcar (Fcar (XCDR (last_c))),
+                     EQ (last_window, window)))
+               {
+                 ASET (recent_keys, last_idx, c);
+                 recorded = 1;
+               }
            }
-       }
     }
   else
+    store_kbd_macro_char (c);
+
+  if (!recorded)
     {
       total_keys++;
       ASET (recent_keys, recent_keys_index, c);
       if (++recent_keys_index >= NUM_RECENT_KEYS)
        recent_keys_index = 0;
     }
+
+  num_nonmacro_input_events++;
       
   /* Write c to the dribble file.  If c is a lispy event, write
      the event's symbol to the dribble file, in <brackets>.  Bleaugh.
@@ -3051,11 +3087,6 @@
 
       fflush (dribble);
     }
-
-  if (!CONSP (c) || !EQ (Qhelp_echo, XCAR (c)))
-    store_kbd_macro_char (c);
-
-  num_nonmacro_input_events++;
 }
 
 Lisp_Object





reply via email to

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