aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2017-09-04 23:04:37 +0100
committerWilfred Hughes <me@wilfred.me.uk>2017-09-04 23:04:37 +0100
commit8ca54f61fae78837b27036df1ecd19b1c5fc3834 (patch)
tree12b2cffc0e533bcc73265ea48b3182d28abb7999
parent91ca5303f7ee2aae6935f0b0a3d9fd8f93ca30e7 (diff)
Add a helpful-key command
Fixes #14
-rw-r--r--CHANGELOG.md3
-rw-r--r--helpful.el12
2 files changed, 15 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0d10af5..a27be4a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,9 @@ Added a command `helpful-callable`, which offers both macros and
functions. This should be a drop-in replacement for
`describe-function`.
+Added a command `helpful-key`, which offers help on keybindings much
+like `describe-key`.
+
# v0.1
First release.
diff --git a/helpful.el b/helpful.el
index 26176e4..f08b1f0 100644
--- a/helpful.el
+++ b/helpful.el
@@ -701,6 +701,18 @@ For example, \"(some-func FOO &optional BAR)\"."
(helpful-update))
;;;###autoload
+(defun helpful-key (key-sequence)
+ "Show help for interactive command bound to KEY-SEQUENCE."
+ (interactive
+ (list (read-key-sequence "Press key: ")))
+ (let ((sym (key-binding key-sequence)))
+ (unless sym
+ (user-error "No command is bound to %s"
+ (key-description key-sequence)))
+ (switch-to-buffer (helpful--buffer sym t))
+ (helpful-update)))
+
+;;;###autoload
(defun helpful-macro (symbol)
"Show help for macro named SYMBOL."
(interactive