helpful

a fork of Wilfred's helpful
git clone https://git.trogloxene.org/helpful.git
Log | Files | Refs | README

commit a6aa35f90f69604b8b49585bfb1195bd641f7de0
parent 7ae5152faacda2a10baa2731e3a56940d25f90c0
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Sun,  2 Apr 2017 09:31:25 +0100

Refactor

Diffstat:
Mhelpful.el | 23+++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/helpful.el b/helpful.el @@ -29,17 +29,22 @@ (defun helpful--buffer (symbol) "Return a buffer to show help for SYMBOL in." (let ((buf (get-buffer-create - (format "*helpful: %s" symbol)))) + (format "*helpful: %s*" symbol)))) (with-current-buffer buf - (setq helpful--sym symbol)))) + (helpful-mode) + (setq helpful--sym symbol)) + buf)) -(defun helpful--update (fn-symbol) - "Update the current *insight* buffer to the latest state of FN-SYMBOL." +(defun helpful-update () + "Update the current *Helpful* buffer to the latest +state of the current symbol." + (interactive) (let ((inhibit-read-only t) (start-pos (point))) (erase-buffer) (insert - (format "Symbol: %s\n" fn-symbol)) + (format "Symbol: %s\n\n" helpful--sym) + "Documentation\n\n") (goto-char start-pos))) (defun helpful (symbol) @@ -49,16 +54,10 @@ nil nil nil nil (symbol-name (symbol-at-point))))) (switch-to-buffer (helpful--buffer symbol)) - (helpful-mode) - (setq-local helpful--sym symbol) - (helpful--update symbol)) + (helpful-update)) (define-derived-mode helpful-mode special-mode "Helpful") -(defun helpful-update () - (interactive) - (helpful--update helpful--sym)) - (define-key helpful-mode-map (kbd "g") #'helpful-update)