emacs-devel
[Top][All Lists]
Advanced

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

Re: this-command oddness


From: Richard Stallman
Subject: Re: this-command oddness
Date: Fri, 29 Aug 2003 11:53:10 -0400

    In the following command:

        (defun db--test-this-command (file)
           (interactive)
           (completing-read "Hit RET: " nil)
           (message "%S" this-command))

    I expected the message "db--test-this-command" in the echo area.
    Instead I get "exit-minibuffer". Furthermore, last-command becomes
    bound to exit-minibuffer rather than db--test-this-command. 

That is because the last command read and executed by Emacs was
exit-minibuffer.

I guess you implicitly expected completing-read to save and restore
these values, but it does not.  I don't think that is a bug.
If you call the function explicitly, the responsibility to manage
these values is yours.

    Similarly, in the following command:

        (defun db--test-this-command (file)
           (interactive "f")
           (message "%S" this-command))

    I expected the message "db--test-this-command" in the echo area.
    Instead I get "minibuffer-complete-and-exit" (after entering a file
    name).

That could be a real bug.  Here is a patch to change it; could you
try it and report if it causes any problems?

*** callint.c.~1.126.~  Sun May 18 08:28:18 2003
--- callint.c   Thu Aug 28 12:59:24 2003
***************
*** 41,46 ****
--- 41,47 ----
  Lisp_Object Vcommand_history;
  
  extern Lisp_Object Vhistory_length;
+ extern Lisp_Object Vthis_original_command, real_this_command;
  
  Lisp_Object Vcommand_debug_status, Qcommand_debug_status;
  Lisp_Object Qenable_recursive_minibuffers;
***************
*** 291,296 ****
--- 292,305 ----
    int key_count;
    int record_then_fail = 0;
  
+   Lisp_Object save_this_command, save_last_command;
+   Lisp_Object save_this_original_command, save_real_this_command;
+ 
+   save_this_command = Vthis_command;
+   save_this_original_command = Vthis_original_command;
+   save_real_this_command = real_this_command;
+   save_last_command = current_kboard->Vlast_command;
+ 
    if (NILP (keys))
      keys = this_command_keys, key_count = this_command_key_count;
    else
***************
*** 395,400 ****
--- 404,415 ----
                XSETCDR (teml, Qnil);
            }
        }
+ 
+       Vthis_command = save_this_command;
+       Vthis_original_command = save_this_original_command;
+       real_this_command= save_real_this_command;
+       current_kboard->Vlast_command = save_last_command;
+ 
        single_kboard_state ();
        return apply1 (function, specs);
      }
***************
*** 840,845 ****
--- 855,865 ----
  
    if (record_then_fail)
      Fbarf_if_buffer_read_only ();
+ 
+   Vthis_command = save_this_command;
+   Vthis_original_command = save_this_original_command;
+   real_this_command= save_real_this_command;
+   current_kboard->Vlast_command = save_last_command;
  
    single_kboard_state ();
  




reply via email to

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