From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: "David Vanderschel" Newsgroups: gmane.emacs.help Subject: Re: How do I bind a macro to a key? Date: Wed, 15 Oct 2003 03:10:39 -0500 Organization: hardly ever ;-) Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org X-Trace: sea.gmane.org 1066205997 2590 80.91.224.253 (15 Oct 2003 08:19:57 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 15 Oct 2003 08:19:57 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed Oct 15 10:19:55 2003 Return-path: Original-Received: from monty-python.gnu.org ([199.232.76.173]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1A9gss-0007cT-01 for ; Wed, 15 Oct 2003 10:19:54 +0200 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1A9gpF-0005mz-Mk for geh-help-gnu-emacs@m.gmane.org; Wed, 15 Oct 2003 04:16:09 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!small1.nntp.aus1.giganews.com!border3.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.texas.net!news.texas.net.POSTED!not-for-mail Original-NNTP-Posting-Date: Wed, 15 Oct 2003 03:10:36 -0500 Original-Newsgroups: gnu.emacs.help X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Original-Lines: 27 Original-X-Trace: sv3-oCpN+uP5HSuIOHlcfWbxIp5d1hySuDEgssOIZi1qeO5yW/iIhp+pjhVuF8w67+1XOdwNr5nCF3F8CxE!SF8VX7QH+mLpkV4TFpx+3ZQjRRXcKfsLThTfvIQxOHDwJe9g9r/AIYZsqffe Original-X-Complaints-To: abuse@texas.net X-DMCA-Complaints-To: abuse@texas.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Original-Xref: shelby.stanford.edu gnu.emacs.help:117263 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.2 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: main.gmane.org gmane.emacs.help:13192 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:13192 "Dan Anderson" in message news: wondered: > Is it possible to create a macro and bind it to a key (or set of keys) > for the rest of the session? ... I do that so frequently that (many years ago) I created a function to facilitate the operation: (defun dv-functionize-kbd-macro (sym) "Make 'function' of kbd macro." (interactive "SName for last kbd macro and the 'function': ") (name-last-kbd-macro sym) (insert ";; \n;; \n") (insert-kbd-macro sym) (insert "(global-set-key \[") (save-excursion (insert (concat "\] '" (symbol-name sym) ")\n\n")) (fill-region (re-search-backward "^(") (re-search-backward "^ ")))) (global-set-key [f12 ?m] 'dv-functionize-kbd-macro) I usually do it in a file which is loaded as part of my initialization, so the 'function' derived from the macro is not just for the current session. Regards, David V.