help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How do I bind a macro to a key?


From: David Vanderschel
Subject: Re: How do I bind a macro to a key?
Date: Wed, 15 Oct 2003 03:10:39 -0500

"Dan Anderson" <dan@mathjunkies.com> in message
news:<mailman.1454.1065750051.21628.help-gnu-emacs@gnu.org> 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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]