From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: yzhh Newsgroups: gmane.emacs.devel Subject: Re: Is there a plan to record kbd macro as elisp code? Date: Sun, 28 Oct 2007 07:13:51 +0000 (UTC) Message-ID: References: <87y7doxmcw.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1193555666 12449 80.91.229.12 (28 Oct 2007 07:14:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 28 Oct 2007 07:14:26 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 28 08:14:28 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Im2Lo-00043u-Mm for ged-emacs-devel@m.gmane.org; Sun, 28 Oct 2007 08:14:25 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Im2Lf-0008D5-M5 for ged-emacs-devel@m.gmane.org; Sun, 28 Oct 2007 03:14:15 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Im2Lb-0008Cl-D9 for emacs-devel@gnu.org; Sun, 28 Oct 2007 03:14:11 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Im2LZ-0008CE-Ff for emacs-devel@gnu.org; Sun, 28 Oct 2007 03:14:10 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Im2LZ-0008C5-Cv for emacs-devel@gnu.org; Sun, 28 Oct 2007 03:14:09 -0400 Original-Received: from mx20.gnu.org ([199.232.41.8]) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Im2LY-0008Kk-SZ for emacs-devel@gnu.org; Sun, 28 Oct 2007 03:14:09 -0400 Original-Received: from main.gmane.org ([80.91.229.2] helo=ciao.gmane.org) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Im2LY-0000HY-38 for emacs-devel@gnu.org; Sun, 28 Oct 2007 03:14:08 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1Im2LS-0001tE-Kw for emacs-devel@gnu.org; Sun, 28 Oct 2007 07:14:02 +0000 Original-Received: from 211.90.238.185 ([211.90.238.185]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 28 Oct 2007 07:14:02 +0000 Original-Received: from yezonghui by 211.90.238.185 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sun, 28 Oct 2007 07:14:02 +0000 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 147 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: main.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 211.90.238.185 (Mozilla/5.0 (X11; U; Linux i686; zh-CN; rv:1.8.1.6) Gecko/20070723 Iceweasel/2.0.0.6 (Debian-2.0.0.6-0etch1+lenny1)) X-detected-kernel: by mx20.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-detected-kernel: by monty-python.gnu.org: Linux 2.6, seldom 2.4 (older, 4) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:81920 Archived-At: Ah, I forgot the code: Index: src/keyboard.c =================================================================== --- src/keyboard.c (revision 4) +++ src/keyboard.c (revision 7) @@ -10020,6 +10020,24 @@ } } This approach looks quite promising. Index: src/keyboard.c =================================================================== --- src/keyboard.c (revision 4) +++ src/keyboard.c (revision 7) @@ -10020,6 +10020,24 @@ } } + /* Record every command for kbd macro's purpose. */ + if (!NILP (current_kboard->defining_kbd_macro) + && NILP (Vexecuting_kbd_macro)) + { + Vkbd_macro_command_history + = Fcons (Fcons (Qexecute_kbd_macro, + Fcons (final, Fcons (prefixarg, Qnil))), + Vkbd_macro_command_history); + + /* Don't keep command history around forever. */ + if (NUMBERP (Vhistory_length) && XINT (Vhistory_length) > 0) + { + tem = Fnthcdr (Vhistory_length, Vkbd_macro_command_history); + if (CONSP (tem)) + XSETCDR (tem, Qnil); + } + } + return Fexecute_kbd_macro (final, prefixarg, Qnil); } Index: src/lisp.h =================================================================== --- src/lisp.h (revision 4) +++ src/lisp.h (revision 7) @@ -2945,6 +2945,7 @@ extern Lisp_Object Qminus, Qplus, Vcurrent_prefix_arg; extern Lisp_Object Vcommand_history; +extern Lisp_Object Vkbd_macro_command_history; extern Lisp_Object Qcall_interactively, Qmouse_leave_buffer_hook; EXFUN (Fcall_interactively, 3); EXFUN (Fprefix_numeric_value, 1); Index: src/callint.c =================================================================== --- src/callint.c (revision 4) +++ src/callint.c (revision 7) @@ -39,6 +39,7 @@ Lisp_Object Vcurrent_prefix_arg, Qminus, Qplus; Lisp_Object Qcall_interactively; Lisp_Object Vcommand_history; +Lisp_Object Vkbd_macro_command_history; extern Lisp_Object Vhistory_length; extern Lisp_Object Vthis_original_command, real_this_command; @@ -377,6 +378,7 @@ GCPRO2 (input, filter_specs); specs = Feval (specs); UNGCPRO; + if (i != num_input_events || !NILP (record_flag)) { /* We should record this command on the command history. */ @@ -397,6 +399,28 @@ } } + /* Record every command for kbd macro's purpose. */ + if ((i != num_input_events) + || (!NILP (current_kboard->defining_kbd_macro) + && NILP (Vexecuting_kbd_macro))) + { + Lisp_Object values; + /* Make a copy of the list of values, for the command history, + and turn them into things we can eval. */ + values = quotify_args (Fcopy_sequence (specs)); + fix_command (input, values); + Vkbd_macro_command_history + = Fcons (Fcons (function, values), Vkbd_macro_command_history); + + /* Don't keep command history around forever. */ + if (INTEGERP (Vhistory_length) && XINT (Vhistory_length) > 0) + { + teml = Fnthcdr (Vhistory_length, Vkbd_macro_command_history); + if (CONSP (teml)) + XSETCDR (teml, Qnil); + } + } + Vthis_command = save_this_command; Vthis_original_command = save_this_original_command; real_this_command= save_real_this_command; @@ -837,6 +861,30 @@ } } + /* Record every command for kbd macro's purpose. */ + if (arg_from_tty || (!NILP (current_kboard->defining_kbd_macro) + && NILP (Vexecuting_kbd_macro))) + { + visargs[0] = function; + for (i = 1; i < count + 1; i++) + { + if (varies[i] > 0) + visargs[i] = Fcons (intern (callint_argfuns[varies[i]]), Qnil); + else + visargs[i] = quotify_arg (args[i]); + } + Vkbd_macro_command_history = Fcons (Flist (count + 1, visargs), + Vkbd_macro_command_history); + /* Don't keep command history around forever. */ + if (INTEGERP (Vhistory_length) && XINT (Vhistory_length) > 0) + { + teml = Fnthcdr (Vhistory_length, Vkbd_macro_command_history); + if (CONSP (teml)) + XSETCDR (teml, Qnil); + } + } + + /* If we used a marker to hold point, mark, or an end of the region, temporarily, convert it to an integer now. */ for (i = 1; i <= count; i++) @@ -963,6 +1011,11 @@ Each command is represented as a form to evaluate. */); Vcommand_history = Qnil; + DEFVAR_LISP ("kbd-macro-command-history", &Vkbd_macro_command_history, + doc: /* List of commands recorded in the last keyboard macro. +Each command is represented as a form to evaluate. */); + Vkbd_macro_command_history = Qnil; + DEFVAR_LISP ("command-debug-status", &Vcommand_debug_status, doc: /* Debugging status of current interactive command. Bound each time `call-interactively' is called;