aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2018-03-02 22:37:20 +0000
committerWilfred Hughes <me@wilfred.me.uk>2018-03-02 22:38:27 +0000
commit5a7329b57c5a0bffc052c9a8353ecb67cecf0616 (patch)
tree7e0503d66aad91734fd74a59cf82591e1444b5d9
parent656ff91eb6094bbd5a78dcd6ef1e9ccb4d257a4d (diff)
Allow users to specify the function used to display the buffer0.8
Fixes #90 Closes #92
-rw-r--r--CHANGELOG.md3
-rw-r--r--helpful.el19
2 files changed, 15 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6132a9a..d43dd96 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,8 @@
# v0.8
+Added setting `helpful-switch-buffer-function` to allow users to
+control how the Helpful buffer is shown.
+
Fixed a crash on functions where the last form in their definition is
a plain symbol.
diff --git a/helpful.el b/helpful.el
index e5efd67..09b6533 100644
--- a/helpful.el
+++ b/helpful.el
@@ -73,10 +73,15 @@ if there are more than this many.
To disable cleanup entirely, set this variable to nil. See also
`helpful-kill-buffers' for a one-off cleanup."
- :group 'help
:type '(choice (const nil) number)
:group 'helpful)
+(defcustom helpful-switch-buffer-function
+ #'pop-to-buffer
+ "Function called to display the *Helpful* buffer."
+ :type 'function
+ :group 'helpful)
+
(defun helpful--kind-name (symbol callable-p)
"Describe what kind of symbol this is."
(cond
@@ -1617,7 +1622,7 @@ escapes that are used by `substitute-command-keys'."
"Show help for function named SYMBOL."
(interactive
(list (helpful--read-symbol "Function: " #'functionp)))
- (pop-to-buffer (helpful--buffer symbol t))
+ (funcall helpful-switch-buffer-function (helpful--buffer symbol t))
(helpful-update))
;;;###autoload
@@ -1625,7 +1630,7 @@ escapes that are used by `substitute-command-keys'."
"Show help for interactive function named SYMBOL."
(interactive
(list (helpful--read-symbol "Command: " #'commandp)))
- (pop-to-buffer (helpful--buffer symbol t))
+ (funcall helpful-switch-buffer-function (helpful--buffer symbol t))
(helpful-update))
;;;###autoload
@@ -1639,7 +1644,7 @@ escapes that are used by `substitute-command-keys'."
(user-error "No command is bound to %s"
(key-description key-sequence)))
((commandp sym)
- (pop-to-buffer (helpful--buffer sym t))
+ (funcall helpful-switch-buffer-function (helpful--buffer sym t))
(helpful-update))
(t
(user-error "%s is bound to %s which is not a command"
@@ -1651,7 +1656,7 @@ escapes that are used by `substitute-command-keys'."
"Show help for macro named SYMBOL."
(interactive
(list (helpful--read-symbol "Macro: " #'macrop)))
- (pop-to-buffer (helpful--buffer symbol t))
+ (funcall helpful-switch-buffer-function (helpful--buffer symbol t))
(helpful-update))
;;;###autoload
@@ -1661,7 +1666,7 @@ escapes that are used by `substitute-command-keys'."
See also `helpful-macro' and `helpful-function'."
(interactive
(list (helpful--read-symbol "Callable: " #'fboundp)))
- (pop-to-buffer (helpful--buffer symbol t))
+ (funcall helpful-switch-buffer-function (helpful--buffer symbol t))
(helpful-update))
(defun helpful--variable-p (symbol)
@@ -1706,7 +1711,7 @@ See also `helpful-callable' and `helpful-variable'."
"Show help for variable named SYMBOL."
(interactive
(list (helpful--read-symbol "Variable: " #'helpful--variable-p)))
- (pop-to-buffer (helpful--buffer symbol nil))
+ (funcall helpful-switch-buffer-function (helpful--buffer symbol nil))
(helpful-update))
;;;###autoload