Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Helpful will try really hard to show the source code. It shows the
source code for interactively defined functions (unlike the built-in
Help) and falls back to the raw sexp if no source is available.

Set `helpful-hide-docstring-in-source` to hide the docstring in source
code.

### View Callers

![screenshot](screenshots/helpful_refs.png)
Expand Down
18 changes: 18 additions & 0 deletions helpful.el
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ To disable cleanup entirely, set this variable to nil. See also
:type 'function
:group 'helpful)


(defcustom helpful-hide-docstring-in-source nil
"If t, hide the the docstring source code header.

This is useful because the formated documentation is already
displayed in it's own header, and you may not want to display it
twice."
:type 'boolean
:group 'helpful)

(defcustom helpful-set-variable-function
(if (< 29 emacs-major-version) #'setopt #'setq)
"Function used by `helpful--set' to interactively set variables."
Expand Down Expand Up @@ -1195,6 +1205,14 @@ hooks.")
(defun helpful--syntax-highlight (source &optional mode)
"Return a propertized version of SOURCE in MODE."
(unless mode
(when helpful-hide-docstring-in-source
(let ((doc-string (ignore-errors
(nth 3 (read source)))))
(when (stringp doc-string)
(setq source
(replace-regexp-in-string
(regexp-quote (prin1-to-string doc-string))
"\"...DOCSTRING...\"" source t t)))))
(setq mode #'emacs-lisp-mode))
(if (or
(< (length source) helpful-max-highlight)
Expand Down