Answers:
这是我在博客中使用的内容。
(define-key org-mode-map "\C-ck" #'endless/insert-key)
(defun endless/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* ((is-org-mode (derived-mode-p 'org-mode))
(tag (if is-org-mode
"@@html:<kbd>%s</kbd>@@"
"<kbd>%s</kbd>")))
(if (null (equal key "\r"))
(insert
(format tag (help-key-description key nil)))
(insert (format tag ""))
(forward-char (if is-org-mode -8 -6)))))
通过调用调用它C-c k
。
C-h k
。<kbd>
标签中。RET
,它将插入标签并在其中留下点(而不是插入任何键),因此您可以键入更复杂的键。org-mode
!之外使用!(define-key org-mode-map (kbd "C-c k") #'endless/insert-key)
和之间有什么区别(define-key org-mode-map (kbd "C-c k") 'endless/insert-key)
?
(help-key-description key nil)
为(mapconcat 'identity (split-string (help-key-description key nil)) "</kbd><kbd>")