From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.devel Subject: Re: Convert a keyboard macro to equivalent Lisp code Date: Mon, 07 Jun 2010 21:35:57 +0300 Organization: JURTA Message-ID: <87bpbn55au.fsf@mail.jurta.org> References: <87fx11mfd3.fsf@mail.jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1275936875 7181 80.91.229.12 (7 Jun 2010 18:54:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 7 Jun 2010 18:54:35 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jun 07 20:54:33 2010 connect(): No such file or directory 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.69) (envelope-from ) id 1OLhSz-0005VS-DK for ged-emacs-devel@m.gmane.org; Mon, 07 Jun 2010 20:54:33 +0200 Original-Received: from localhost ([127.0.0.1]:36529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLhSy-0006rb-KL for ged-emacs-devel@m.gmane.org; Mon, 07 Jun 2010 14:54:32 -0400 Original-Received: from [140.186.70.92] (port=44934 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OLhQf-0005N1-S3 for emacs-devel@gnu.org; Mon, 07 Jun 2010 14:52:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OLhQe-0003Hf-GW for emacs-devel@gnu.org; Mon, 07 Jun 2010 14:52:09 -0400 Original-Received: from smtp-out1.starman.ee ([85.253.0.3]:44912 helo=mx1.starman.ee) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OLhQe-0003HU-4j for emacs-devel@gnu.org; Mon, 07 Jun 2010 14:52:08 -0400 X-Virus-Scanned: by Amavisd-New at mx1.starman.ee Original-Received: from mail.starman.ee (82.131.35.211.cable.starman.ee [82.131.35.211]) by mx1.starman.ee (Postfix) with ESMTP id 31B543F419D for ; Mon, 7 Jun 2010 21:52:05 +0300 (EEST) In-Reply-To: <87fx11mfd3.fsf@mail.jurta.org> (Juri Linkov's message of "Sat, 05 Jun 2010 22:57:04 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (x86_64-pc-linux-gnu) X-detected-operating-system: by eggs.gnu.org: GNU/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:125604 Archived-At: To get useful results, some commands should provide their arguments explicitly in the interactive spec instead of relying on global variables. So instead of useless `(self-insert-command 1)' typing `A' will record `(self-insert-command 1 65)' with the following patch. The same is for isearch. === modified file 'src/cmds.c' --- src/cmds.c 2010-05-25 09:36:21 +0000 +++ src/cmds.c 2010-06-07 18:34:33 +0000 @@ -331,19 +331,23 @@ /* Note that there's code in command_loop_1 which typically avoids calling this. */ -DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 1, "p", +DEFUN ("self-insert-command", Fself_insert_command, Sself_insert_command, 1, 2, + "(list (prefix-numeric-value current-prefix-arg) last-command-event)", doc: /* Insert the character you type. Whichever character you type to run this command is inserted. Before insertion, `expand-abbrev' is executed if the inserted character does not have word syntax and the previous character in the buffer does. After insertion, the value of `auto-fill-function' is called if the `auto-fill-chars' table has a non-nil value for the inserted character. */) - (n) - Lisp_Object n; + (n, last_char) + Lisp_Object n, last_char; { int remove_boundary = 1; CHECK_NUMBER (n); + if (NILP (last_char)) + last_char = last_command_event; + if (!EQ (Vthis_command, current_kboard->Vlast_command)) nonundocount = 0; @@ -365,11 +369,11 @@ (at your option) any later version. current_buffer->undo_list = XCDR (current_buffer->undo_list); /* Barf if the key that invoked this was not a character. */ - if (!CHARACTERP (last_command_event)) + if (!CHARACTERP (last_char)) bitch_at_user (); { int character = translate_char (Vtranslation_table_for_input, - XINT (last_command_event)); + XINT (last_char)); if (XINT (n) >= 2 && NILP (current_buffer->overwrite_mode)) { XSETFASTINT (n, XFASTINT (n) - 2); === modified file 'lisp/isearch.el' --- lisp/isearch.el 2010-05-20 23:16:04 +0000 +++ lisp/isearch.el 2010-06-06 18:30:52 +0000 @@ -1995,10 +1995,10 @@ (defun isearch-return-char () (isearch-process-search-char ?\n)) (make-obsolete 'isearch-return-char 'isearch-printing-char "19.7") -(defun isearch-printing-char () +(defun isearch-printing-char (&optional char) "Add this ordinary printing character to the search string and search." - (interactive) - (let ((char last-command-event)) + (interactive (list last-command-event)) + (let ((char (or char last-command-event))) (if (= char ?\S-\ ) (setq char ?\s)) (if current-input-method -- Juri Linkov http://www.jurta.org/emacs/