commit 677c534688a3b2fb478dd73d0dbac50062fea124
parent 3b2141975f9f54f7433b9ea9947df0849864a26a
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Wed, 6 Dec 2017 22:42:24 +0000
Improve buffer name
Buffer names now take the form *helpful function: foo* or
*helpful variable: foo* so we can distinguish the different
namespaces more clearly.
Closes #55
Diffstat:
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/helpful.el b/helpful.el
@@ -56,11 +56,21 @@
"We store a reference to the buffer we were called from, so we can
show the value of buffer-local variables.")
+(defun helpful--kind-name (symbol callable-p)
+ "Describe what kind of symbol this is."
+ (cond
+ ((not callable-p) "variable")
+ ((commandp symbol) "command")
+ ((macrop symbol) "macro")
+ ((functionp symbol) "function")))
+
(defun helpful--buffer (symbol callable-p)
"Return a buffer to show help for SYMBOL in."
(let ((current-buffer (current-buffer))
(buf (get-buffer-create
- (format "*helpful: %s*" symbol))))
+ (format "*helpful %s: %s*"
+ (helpful--kind-name symbol callable-p)
+ symbol))))
(with-current-buffer buf
(helpful-mode)
(setq helpful--sym symbol)
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -127,7 +127,7 @@ buffers lying around."
(let ((initial-buffers (buffer-list))
expected-buffers results-buffer)
(helpful-function #'enable-theme)
- (setq results-buffer (get-buffer "*helpful: enable-theme*"))
+ (setq results-buffer (get-buffer "*helpful command: enable-theme*"))
(setq expected-buffers
(cons results-buffer
initial-buffers))