commit 134b10848c6cc8529903562d2ab61bd347ee1da6
parent e6efb25015180049d624c2e86f956cfe76ffe125
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Wed, 13 Dec 2017 22:45:05 +0000
Calculate C paths relative to find-function-C-source-directory
Fixes #65
Diffstat:
4 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
@@ -1,2 +1,5 @@
.cask
*.elc
+
+emacs-25.3
+emacs-25.3.tar.gz
diff --git a/.travis.yml b/.travis.yml
@@ -1,6 +1,15 @@
language: generic
sudo: false
+
+cache:
+ directories:
+ - emacs-25.3
+
before_install:
+ # A copy of the emacs source code.
+ - wget http://ftpmirror.gnu.org/emacs/emacs-25.3.tar.gz
+ - tar -xzf emacs-25.3.tar.gz
+
- curl -fsSkL https://gist.github.com/rejeep/ebcd57c3af83b049833b/raw > x.sh && source ./x.sh
- evm install $EVM_EMACS --use --skip
- cask
diff --git a/helpful.el b/helpful.el
@@ -401,6 +401,11 @@ for killing the newly created buffer."
;; Narrowing has been fixed upstream:
;; http://git.savannah.gnu.org/cgit/emacs.git/commit/?id=abd18254aec76b26e86ae27e91d2c916ec20cc46
(-when-let ((base-sym . path) (find-function-library sym))
+ (when (string-match "\\`src/\\(.*\\.\\(c\\|m\\)\\)\\'" path)
+ (cl-assert find-function-C-source-directory)
+ (setq path (f-expand (match-string 1 path)
+ find-function-C-source-directory)))
+
;; Open `path' ourselves. If the user has already opened it,
;; we ensure that we don't change their narrowing or point
;; position when we search it.
diff --git a/test/unit-test.el b/test/unit-test.el
@@ -79,7 +79,17 @@
(ert-deftest helpful-callable ()
;; We should not crash when looking at macros.
- (helpful-callable 'when))
+ (helpful-callable 'when)
+ ;; Special forms should work too.
+ (helpful-callable 'if)
+ ;; Smoke test for special forms when we have the Emacs C source
+ ;; loaded.
+ (let* ((emacs-src-path (f-join default-directory "emacs-25.3" "src")))
+ (if (f-exists-p emacs-src-path)
+ (let ((find-function-C-source-directory emacs-src-path))
+ (helpful-callable 'if))
+ (message "No Emacs source code found at %S, skipping test."
+ emacs-src-path))))
(ert-deftest helpful--no-symbol-properties ()
"Helpful should handle functions without any symbol properties."