From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Michael Welsh Duggan Newsgroups: gmane.emacs.devel Subject: Re: Has anybody got a tool for manipulating dribble files? Date: Wed, 12 Oct 2011 22:21:26 -0400 Message-ID: <874nzd6389.fsf@maru.md5i.com> References: <20111012190105.GB2870@acm.acm> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: dough.gmane.org 1318472503 21400 80.91.229.12 (13 Oct 2011 02:21:43 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 13 Oct 2011 02:21:43 +0000 (UTC) Cc: emacs-devel@gnu.org To: Alan Mackenzie Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Oct 13 04:21:40 2011 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([140.186.70.17]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1REAvT-0004zg-Gf for ged-emacs-devel@m.gmane.org; Thu, 13 Oct 2011 04:21:39 +0200 Original-Received: from localhost ([::1]:50771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REAvS-0003g9-Vl for ged-emacs-devel@m.gmane.org; Wed, 12 Oct 2011 22:21:38 -0400 Original-Received: from eggs.gnu.org ([140.186.70.92]:46503) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REAvQ-0003g0-8A for emacs-devel@gnu.org; Wed, 12 Oct 2011 22:21:37 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1REAvO-0007p5-TF for emacs-devel@gnu.org; Wed, 12 Oct 2011 22:21:36 -0400 Original-Received: from md5i.com ([75.151.244.229]:33646 helo=maru.md5i.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1REAvO-0007ok-KX for emacs-devel@gnu.org; Wed, 12 Oct 2011 22:21:34 -0400 Original-Received: from md5i by maru.md5i.com with local (Exim 4.76) (envelope-from ) id 1REAvH-000443-2G; Wed, 12 Oct 2011 22:21:27 -0400 In-Reply-To: <20111012190105.GB2870@acm.acm> (Alan Mackenzie's message of "Wed, 12 Oct 2011 19:01:05 +0000") User-Agent: Gnus/5.110018 (No Gnus v0.18) Emacs/24.0.50 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 75.151.244.229 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:145091 Archived-At: --=-=-= Content-Type: text/plain Alan Mackenzie writes: > Hi, Emacs. > > I've got a rather largish dribble-file (thanks Michael!) for recreating > a bug. Does anybody here have or know about a tool which can replay > (partially or wholly) such a file, or anything similar? I asked this a little while ago, and got no response. So I wrote the following function: --=-=-= Content-Type: application/emacs-lisp Content-Disposition: inline; filename=dribble.el Content-Transfer-Encoding: quoted-printable (defun kbd-macro-from-dribble (file) "Set the `last-kbd-macro' from the dribble file FILE." (interactive "f") (with-current-buffer (find-file-noselect file nil t) (goto-char (point-min)) (let ((keys)) (while (not (eobp)) (cond=20 ((looking-at " 0x\\([0-9a-f]\\{7\\}\\)") (goto-char (match-end 0)) (push (string-to-number (match-string 1) 16) keys)) ((looking-at "<\\([^<> \t\n]+\\)>") (goto-char (match-end 0)) (when (match-beginning 1) (let ((key (intern-soft (match-string 1)))) (unless (memq key '(help-echo switch-frame)) (push key keys))))) (t (push (following-char) keys) (forward-char 1)))) (setq last-kbd-macro (vconcat (nreverse keys)))))) --=-=-= Content-Type: text/plain This function reads a dribble file and creates a keyboard macro from it. It is heuristic in nature. You cannot tell the difference between `RET' being pressed and the key sequence "" in a dribble file, along with a couple of other similar things. Once you have the macro, it can then be edited using M-x edit-kbd-macro (of `C-x e'). Unfortunately, the macro will stop on any C-g or any command that raises an error, so the macro must be edited to elide these. In this particular case, I have done the work, and I will be posting an exact recipe for recreating the problem in Bug 9560. (Once nice thing about using a keyboard macro to replicate the problem is that you can trim it to look at intermediate state.) -- Michael Welsh Duggan (md5i@md5i.com) --=-=-=--