aboutsummaryrefslogtreecommitdiff
path: root/helpful.el
diff options
context:
space:
mode:
Diffstat (limited to 'helpful.el')
-rw-r--r--helpful.el33
1 files changed, 32 insertions, 1 deletions
diff --git a/helpful.el b/helpful.el
index 9dfd4be..49ad48d 100644
--- a/helpful.el
+++ b/helpful.el
@@ -2482,6 +2482,25 @@ or :foo."
(or (fboundp symbol)
(helpful--variable-p symbol)))
+(defun helpful--bookmark-jump (bookmark)
+ "Create and switch to helpful bookmark BOOKMARK."
+ (let ((callable-p (bookmark-prop-get bookmark 'callable-p))
+ (sym (bookmark-prop-get bookmark 'sym))
+ (position (bookmark-prop-get bookmark 'position)))
+ (if callable-p
+ (helpful-callable sym)
+ (helpful-variable sym))
+ (goto-char position)))
+
+(defun helpful--bookmark-make-record ()
+ "Create a bookmark record for helpful buffers.
+
+See docs of `bookmark-make-record-function'."
+ `((sym . ,helpful--sym)
+ (callable-p . ,helpful--callable-p)
+ (position . ,(point))
+ (handler . helpful--bookmark-jump)))
+
(defun helpful--convert-c-name (symbol var)
"Convert SYMBOL from a C name to an Elisp name.
E.g. convert `Fmake_string' to `make-string' or
@@ -2620,13 +2639,25 @@ See also `helpful-max-buffers'."
map)
"Keymap for `helpful-mode'.")
+(declare-function bookmark-prop-get "bookmark" (bookmark prop))
+(declare-function bookmark-make-record-default "bookmark"
+ (&optional no-file no-context posn))
+;; Ensure this variable is defined even if bookmark.el isn't loaded
+;; yet. This follows the pattern in help-mode.el.gz.
+;; TODO: find a cleaner solution.
+(defvar bookmark-make-record-function)
+
(define-derived-mode helpful-mode special-mode "Helpful"
"Major mode for *Helpful* buffers."
(add-hook 'xref-backend-functions #'elisp--xref-backend nil t)
(setq imenu-create-index-function #'helpful--imenu-index)
;; Prevent imenu converting "Source Code" to "Source.Code".
- (setq-local imenu-space-replacement " "))
+ (setq-local imenu-space-replacement " ")
+
+ ;; Enable users to bookmark helpful buffers.
+ (set (make-local-variable 'bookmark-make-record-function)
+ #'helpful--bookmark-make-record))
(provide 'helpful)
;;; helpful.el ends here