emacs-devel
[Top][All Lists]
Advanced

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

Re: Strange behavior of C-u in the presence of sit-for in p-c-h


From: Kim F. Storm
Subject: Re: Strange behavior of C-u in the presence of sit-for in p-c-h
Date: Thu, 19 Oct 2006 23:09:28 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Chong Yidong <address@hidden> writes:

> Here is an easy way to reproduce the underlying bug:
>
> (defun foo ()
>   (interactive)
>   (universal-argument)
>   (push ?a unread-command-events))
>
> M-x foo RET
>
> The expected result is aaaa, but in fact nothing is printed.


Here is a simple patch which fixes the problem AFAICS.

It uses a special event code (t . EVENT) in unread-command-events
to specify that EVENT is _not_ reread.  Of course, this should be
documented in unread-command-events if people think this fix is ok.


*** keyboard.c  10 Oct 2006 10:33:25 +0200      1.878
--- keyboard.c  19 Oct 2006 23:00:23 +0200      
***************
*** 2537,2542 ****
--- 2537,2554 ----
        c = XCAR (Vunread_command_events);
        Vunread_command_events = XCDR (Vunread_command_events);
  
+       reread = 1;
+ 
+       /* Undo what sit-for did when it unread additional keys
+        inside universal-argument.  */
+ 
+       if (CONSP (c)
+         && EQ (XCAR (c), Qt))
+       {
+         reread = 0;
+         c = XCDR (c);
+       }
+ 
        /* Undo what read_char_x_menu_prompt did when it unread
         additional keys returned by Fx_popup_menu.  */
        if (CONSP (c)
***************
*** 2550,2556 ****
          && (EQ (c, Qtool_bar) || EQ (c, Qmenu_bar)))
        *used_mouse_menu = 1;
  
-       reread = 1;
        goto reread_for_input_method;
      }
  
--- 2562,2567 ----


Index: subr.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/subr.el,v
retrieving revision 1.530
diff -c -r1.530 subr.el
*** subr.el     18 Oct 2006 10:56:46 -0000      1.530
--- subr.el     19 Oct 2006 21:08:24 -0000
***************
*** 1752,1759 ****
      (or nodisp (redisplay))
      (let ((read (read-event nil nil seconds)))
        (or (null read)
!         (progn (push read unread-command-events)
!                nil))))))
  
  ;;; Atomic change groups.
  
--- 1758,1768 ----
      (or nodisp (redisplay))
      (let ((read (read-event nil nil seconds)))
        (or (null read)
!         (progn
!           (if (eq overriding-terminal-local-map universal-argument-map)
!               (setq read (cons t read)))
!           (push read unread-command-events)
!           nil))))))
  
  ;;; Atomic change groups.
  

-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

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