A New Trick For Marking Up Key Sequences in Emacs

Frozenlock left a comment to an old post of mine about Marking Up Key Sequences For HTML. He said he liked the way Xah Lee and I mark up Emacs keys sequences but that he didn’t like having to write ctrl+x b to get 【Ctrl+x b】 so he wrote a little hack that allows him to enter the actual key strokes and have the appropriate markup inserted at the point.

It turns out to be pretty easy to do. If I were starting from scratch (or weren’t so lazy) I’d modify my prettify-key-sequence function to accept the actual keystrokes and output the markup. Frozenlock uses the macro method that I used before I wrote prettify-key-sequence so there isn’t quite as much control over the final output but it works well for most cases. If you want to use markedup key sequences, I’d look at Frozenlock’s method and consider integrating it into something like prettify-key-sequence.

This entry was posted in Blogging and tagged , . Bookmark the permalink.

5 Responses to A New Trick For Marking Up Key Sequences in Emacs

  1. Aankhen says:

    Out of curiosity, why do you use <span class="key"> instead of <kbd>? (Or maybe something like <span class="keysequence"><kbd>Ctrl</kbd>+<kbd>x</kbd> […].)

    • jcs jcs says:

      When I first did it I used <key>…</key> but WordPress disappeared the tags so I had to drop back to the span method, which WordPress recognizes.

      • Aankhen says:

        Sorry, not sure I understand—did you use kbd or key? The latter isn’t an HTML element, so WordPress may be scrubbing it.

        • jcs jcs says:

          I did use key. I’m not really a HTML guru and didn’t know about kbd–I just made the key element up. Perhaps I’ll experiment. Thanks for pointing that out to me.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>