helpful

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

commit 01052ed5645e2f1e852909ed361d7c93796295d3
parent de86442308c5ce9c7d8ca1f759a663af0c4e4c04
Author: Wilfred Hughes <me@wilfred.me.uk>
Date:   Fri,  6 Jul 2018 15:59:24 +0100

Don't try to find definitions for primitives if we don't have a source path

Add an assertion to enforce this.

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

diff --git a/helpful.el b/helpful.el @@ -1106,6 +1106,12 @@ buffer." ;; variables. It prompts the user, and we discard the buffer ;; afterwards anyway. (enable-local-variables nil)) + ;; We shouldn't be called on primitive functions if we don't have + ;; a directory of Emacs C sourcecode. + (cl-assert + (or find-function-C-source-directory + (not primitive-p))) + (when (and (symbolp sym) callable-p) (-let [(_ . src-path) (find-function-library sym)] (setq path src-path))) @@ -1178,11 +1184,6 @@ buffer." (error nil)))) (list buf pos opened))) -(defun helpful--source-path (buf) - "Given a source buffer BUF, return its path." - (when buf - (buffer-file-name buf))) - (defun helpful--reference-positions (sym callable-p buf) "Return all the buffer positions of references to SYM in BUF." (-let* ((forms-and-bufs @@ -1679,11 +1680,14 @@ state of the current symbol." (t "Function"))) (look-for-src (or (not primitive-p) find-function-C-source-directory)) - ((buf pos opened) (helpful--definition helpful--sym helpful--callable-p)) + ((buf pos opened) + (if look-for-src + (helpful--definition helpful--sym helpful--callable-p) + '(nil nil nil))) (source (when look-for-src (helpful--source helpful--sym helpful--callable-p buf pos))) - (source-path (when (and look-for-src (symbolp helpful--sym)) - (helpful--source-path buf))) + (source-path (when buf + (buffer-file-name buf))) (references (helpful--calculate-references helpful--sym helpful--callable-p source-path)))