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: Is there a plan to record kbd macro as elisp code? Date: Sun, 28 Oct 2007 03:34:46 +0200 Organization: JURTA Message-ID: <87d4v09f6h.fsf@jurta.org> References: <87y7doxmcw.fsf@jurta.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1193537067 11551 80.91.229.12 (28 Oct 2007 02:04:27 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 28 Oct 2007 02:04:27 +0000 (UTC) Cc: yzhh , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 28 03:04: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 1IlxVr-0003gq-Si for ged-emacs-devel@m.gmane.org; Sun, 28 Oct 2007 03:04:28 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IlxVi-0006oM-UZ for ged-emacs-devel@m.gmane.org; Sat, 27 Oct 2007 22:04:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IlxUZ-000592-Dn for emacs-devel@gnu.org; Sat, 27 Oct 2007 22:03:07 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IlxUY-000585-Q7 for emacs-devel@gnu.org; Sat, 27 Oct 2007 22:03:07 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IlxUY-00057r-K4 for emacs-devel@gnu.org; Sat, 27 Oct 2007 22:03:06 -0400 Original-Received: from mailman.kiev.sovam.com ([89.162.150.100]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IlxUX-0005Rf-SH for emacs-devel@gnu.org; Sat, 27 Oct 2007 22:03:06 -0400 Original-Received: from relay01.kiev.sovam.com ([62.64.120.200]) by mailman.kiev.sovam.com with esmtp (Exim 4.63 (FreeBSD)) (envelope-from ) id 1Im0Ih-000IKy-US; Sun, 28 Oct 2007 05:03:03 +0000 Original-Received: from [83.170.232.243] (helo=smtp.svitonline.com) by relay01.kiev.sovam.com with esmtp (Exim 4.67) (envelope-from ) id 1IlxUV-000JxH-2t; Sun, 28 Oct 2007 04:03:03 +0200 In-Reply-To: (Stefan Monnier's message of "Sat\, 27 Oct 2007 21\:14\:23 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/23.0.50 (gnu/linux) X-Scanner-Signature: 7ffaa6bc246e67c9b1a22e0c753f4a43 X-DrWeb-checked: yes X-SpamTest-Envelope-From: juri@jurta.org X-SpamTest-Group-ID: 00000000 X-SpamTest-Header: Not Detected X-SpamTest-Info: Profiles 1690 [Oct 27 2007] X-SpamTest-Info: helo_type=3 X-SpamTest-Info: {HEADERS: header Content-Type found without required header Content-Transfer-Encoding} X-SpamTest-Method: none X-SpamTest-Rate: 25 X-SpamTest-Status: Not detected X-SpamTest-Status-Extended: not_detected X-SpamTest-Version: SMTP-Filter Version 3.0.0 [0255], KAS30/Release X-detected-kernel: by monty-python.gnu.org: FreeBSD 6.x (1) 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:81911 Archived-At: > OTOH I do expect that it can be very tricky to recover the structure from > just the key sequence: e.g. after a keybinding that may or may not present > a minibuffer prompt, figuring out whether the rest of the keys were sent to > the minibuffer or to the next command can be impossible without guessing. Yes, and in the converted Lisp programs emulating the logic of minibuffer processing is useless. What would be useful to generate in Lisp programs are executed commands with their arguments no matter how these arguments were specified by the user. > This doesn't sound too bad. Another approach would be to advise > `call-interactively'. > > This may require changes at the C level so as to make sure that calls to > Fcall_interactively are never made directly but always go through the > `call-interactively' symbol. > > With an exhaustive around advice on call-interactively, you should be > able to get a fairly reliable trace. But `call-interactively' doesn't have an argument that contains the arguments of the called command. I think we should avoid generating Lisp code that read command arguments. > But even a reliable trace will encounter the problems mentioned by Kim, and > in order to get /good/ Elisp code (rather than just /working/ Elisp code), > a fair bit of post-processing will be needed with ad-hoc rewrites. I think the goal is not to produce Lisp code exactly equivalent to the keyboard macro, but a useful basis for writing a new Lisp function. -- Juri Linkov http://www.jurta.org/emacs/