It doesn't take a psychic to guess the <kbd> tag will be useful when
writing about Emacs. When Jorge Navarro asked for the best way to do this, over
at Emacs.SE, I thought I'd share the snippet I use.
This simple command will ask for a key sequence (just like C-h
k would) and will insert it for you. If you want to write the
sequence manually, just hit RET when prompted. C-c k feels
like a nice binding for it.
(eval-after-load'ox-html;; If you prefer to use ~ for <code> tags. Replace "code" with;; "verbatim" here, and replace "~" with "=" below.'(push'(code."<kbd>%s</kbd>")org-html-text-markup-alist))(define-keyorg-mode-map"\C-ck"#'endless/insert-key)(defunendless/insert-key(key)"Ask for a key then insert its description.
Will work on both org-mode and any mode that accepts plain html."(interactive"kType key sequence: ")(let*((orgp(derived-mode-p'org-mode))(tag(iforgp"~%s~""<kbd>%s</kbd>")))(if(null(equalkey"\C-m"))(insert(formattag(help-key-descriptionkeynil)));; If you just hit RET.(insert(formattag""))(forward-char(iforgp-1-6)))))
It should work in both org-mode and html-like modes.
Update <2014-11-30 Sun>
A big kudos to u/abo-abo, for suggesting the use of ~.
Inserting the kbd tag in interactively
17 Nov 2014, by Artur Malabarba.Emacs.SE Lessons post series
It doesn't take a psychic to guess the
<kbd>
tag will be useful when writing about Emacs. When Jorge Navarro asked for the best way to do this, over at Emacs.SE, I thought I'd share the snippet I use.This simple command will ask for a key sequence (just like C-h k would) and will insert it for you. If you want to write the sequence manually, just hit RET when prompted. C-c k feels like a nice binding for it.
It should work in both
org-mode
andhtml
-like modes.Update <2014-11-30 Sun>
A big kudos to u/abo-abo, for suggesting the use of
~
.Tags: blog, keybind, org-mode, init.el, emacs,
Emacs Rocks Again! »
« New in Emacs 25.1: Query-replace history is enhanced.
Related Posts
A few paredit keys that take over the world in keybind
Fill and unfill paragraphs with a single key in keybind
Disable Mouse only inside Emacs in keybind
Content © 2019, All rights reserved. Icons under CC3.0.