helpful

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

commit d155add4af76df4b342250dec7ced57f58400465
parent a102f46361a41798d8f7ef429f244bb7a81a5868
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Wed, 13 Mar 2019 00:31:02 +0000

Consider after-change-functions to be a hook

Diffstat:
MCHANGELOG.md | 3+++
Mhelpful.el | 16++++++++++++----
2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md @@ -3,6 +3,9 @@ Fixed a minor docstring formatting issue when keymap references were on their own line. +Symbols of the form `foo-functions` (e.g. `after-change-functions`) +are now rendered as hooks. + # v0.16 Improved wording when looking at aliases. diff --git a/helpful.el b/helpful.el @@ -1935,6 +1935,16 @@ may contain duplicates." (when (autoloadp fn-obj) (autoload-do-load fn-obj))))) +(defun helpful--hook-p (symbol value) + "Does SYMBOL look like a hook?" + (and + (or + (s-ends-with-p "-hook" (symbol-name symbol)) + ;; E.g. `after-change-functions', which can be used with + ;; `add-hook'. + (s-ends-with-p "-functions" (symbol-name symbol))) + (consp value))) + (defun helpful-update () "Update the current *Helpful* buffer to the latest state of the current symbol." @@ -1990,8 +2000,7 @@ state of the current symbol." (multiple-views-p (or (stringp val) (keymapp val) - (and (s-ends-with-p "-hook" (symbol-name sym)) - (consp val))))) + (helpful--hook-p sym val)))) (insert (helpful--heading (cond @@ -2022,8 +2031,7 @@ state of the current symbol." ;; links to the commands bound. ((keymapp val) (helpful--format-keymap val)) - ((and (s-ends-with-p "-hook" (symbol-name sym)) - (consp val)) + ((helpful--hook-p sym val) (helpful--format-hook val)) (t (helpful--pretty-print val)))