From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Convert a keyboard macro to equivalent Lisp code Date: Wed, 09 Jun 2010 10:17:29 -0400 Message-ID: References: <87fx11mfd3.fsf@mail.jurta.org> <87bpbn55au.fsf@mail.jurta.org> <87iq5uuemn.fsf@mail.jurta.org> <87y6eo3a4r.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 1276093235 12921 80.91.229.12 (9 Jun 2010 14:20:35 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Wed, 9 Jun 2010 14:20:35 +0000 (UTC) Cc: emacs-devel@gnu.org To: Juri Linkov Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jun 09 16:20:34 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 1OMM8s-0008My-ER for ged-emacs-devel@m.gmane.org; Wed, 09 Jun 2010 16:20:30 +0200 Original-Received: from localhost ([127.0.0.1]:48125 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMM6D-0004qm-4z for ged-emacs-devel@m.gmane.org; Wed, 09 Jun 2010 10:17:45 -0400 Original-Received: from [140.186.70.92] (port=58381 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OMM60-0004nR-1A for emacs-devel@gnu.org; Wed, 09 Jun 2010 10:17:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OMM5y-0002WZ-Vk for emacs-devel@gnu.org; Wed, 09 Jun 2010 10:17:31 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.181]:5919 helo=ironport2-out.pppoe.ca) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OMM5y-0002WK-Tg for emacs-devel@gnu.org; Wed, 09 Jun 2010 10:17:30 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AvsEADs/D0xFxIMM/2dsb2JhbACeRXK+BIUYBIxw X-IronPort-AV: E=Sophos;i="4.53,391,1272859200"; d="scan'208";a="67670098" Original-Received: from 69-196-131-12.dsl.teksavvy.com (HELO pastel.home) ([69.196.131.12]) by ironport2-out.pppoe.ca with ESMTP; 09 Jun 2010 10:17:29 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id 39EE881B5; Wed, 9 Jun 2010 10:17:29 -0400 (EDT) In-Reply-To: <87y6eo3a4r.fsf@mail.jurta.org> (Juri Linkov's message of "Wed, 09 Jun 2010 11:34:04 +0300") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. 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:125670 Archived-At: > But your objection prompted me to look closely at `self-insert-command', > and I found another reason (`translate_char') why it won't work ;-) AFAIK translate-char is not used. I suggested to get rid of it in Emacs-23, so it's obsolete since Emacs-23.1. AFAIK it's only ever been used for Emacs-22's char-unification support. >> I'm heading towards a special "recording&running macro" mode where >> various commands may have a slightly different behavior (less DWIMish, >> more amenable to scripting, more amenable to transforming into Elisp >> code), so "verifying" might not be the right approach since a different >> behavior might not be a problem but a feature. > Then it's a different feature. Yes and no: yes, in the sense that the difference is considered a feature, but no in the sense that it's *very* similar, used for the same purpose, and could use the same keybindings. > This is more like command translation during recording and running > a macro. This is already possible to do without core support with: If it can be done without changing C code, that's an advantage. > (add-hook 'pre-command-hook > (lambda () > (when (or defining-kbd-macro executing-kbd-macro) > (cond ((eq this-command 'next-line) > (setq this-command 'forward-line)))))) Yuck. > (add-hook 'pre-command-hook > (lambda () > (when (or defining-kbd-macro executing-kbd-macro) > (cond ((memq this-command '(next-line previous-line)) > (setq line-move-visual nil)))))) > (add-hook 'post-command-hook > (lambda () > (when (or defining-kbd-macro executing-kbd-macro) > (cond ((memq this-command '(next-line previous-line)) > (setq line-move-visual t)))))) Even more yuck! Those settings would be enabled disabled when you enter/leave the macro recording/running mode rather than around each command. Still, the above does not record the commands, so there's more work to do. Stefan