Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 868527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:09:16+00:00 2026-05-15T10:09:16+00:00

I usually define new keybindings in emacs using "C-x (" –> (command kmacro-start-macro) "C-x

  • 0

I usually define new keybindings in emacs using

"C-x (" --> (command kmacro-start-macro)
"C-x )" --> (kmacro-end-macro)
(name-last-kbd-macro)
(insert-kbd-macro)

But the code it generates looks different than the code I read and modify in various major / minor modes and other emacs utilities.
I recently came across this blog post that clears up some of my confusion.

Is there an emacs tool that simplifies keystroke representation ?
Ideally one that translates from ahk keystroke notation to any sane emacs keystroke notation.

Edit: some other reading to clear my confusion:
keybinding guide by Jari Aalto.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:09:17+00:00Added an answer on May 15, 2026 at 10:09 am

    The sequence you specify does simplify the keystroke representation. What you’re left with is essentially the set of keystrokes you typed.

    It’s already been asked if you can convert an emacs macro into elisp.

    Perhaps you’re asking if it could be made more human readable?
    If so, then you’re in luck.

    You can use the kbd macro to convert the printed representation of keystrokes into the equivalent vector of keystrokes.

    For example, the sequence which results in a query-replace of 3 with tj looks like: M-% 3 RET tj RET !

    Well, you can manually set that up with:

    (fset 'my-hand-crafted-kbd-macro (kbd "M-% 3 RET tj RET !"))
    

    And this piece of elisp code should generate the above for you if you have named your macro 'my-hand-crafted-kbd-macro:

    (defun insert-pretty-kbd-macro (macro-name)
      (interactive (list (intern (completing-read
                                  "Insert kbd macro (name): "
                                  obarray
                                  (lambda (elt)
                                    (and (fboundp elt)
                                         (or (stringp (symbol-function elt))
                                             (vectorp (symbol-function elt))
                                             (get elt 'kmacro))))
                                  t))))
      (interactive)
      (insert "(fset '")
      (prin1 macro-name (current-buffer))
      (insert "\n   (kbd \"")
      (insert (key-description (symbol-function macro-name)))
      (insert "\"))\n"))
    

    To get this to happen automatically when you finish a keyboard macro C-x ), you can use this advice:

    (defadvice kmacro-end-macro (after kmacro-end-macro-name-it-and-insert activate)
      "user wants to insert elisp to reproduce the last kbd macro"
      (let ((name (read-string "Name for this kbd macro: ")))
        (insert "(fset '")
        (insert name)
        (insert "\n   (kbd \"")
        (insert (key-description last-kbd-macro))
        (insert "\"))\n")))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I usually tend to define the model layer of my apps using POJO's, such
Usually we define iis web sites which allow anonymous authentication to run under the
usually a requirejs module looks like: define('ModuleName', ['jquery', 'underscore', 'backbone'], function($, _, Backbone){ });
I am trying to define dynamically variables. I am using a function for this,
The application name usually is defined by the TARGET = MyApplication statement in the
I'm new to MySQL procedures. I need to emulate some code that I usually
I have defined a few different functions in my .bash_profile . I usually remember
In Objective-C, I usually see methods that return a dynamically typed object defined as
Usually I worked with PostgreSQL and never had a problem, but now I need
Usually I prefer to write my own solutions for trivial problems because generally plugins

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.