aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilfred Hughes <me@wilfred.me.uk>2018-01-20 11:22:12 +0000
committerWilfred Hughes <me@wilfred.me.uk>2018-01-20 11:22:12 +0000
commitffc16a64b2d594b713580194558cf997c3e5ebad (patch)
tree5ed8b41a8eb8532084d4599f2e0c930dd0e32534
parentb968411f42a8f923e80d609d4219d3d7362a2d03 (diff)
Be defensive against missing primitive source code
If find-function-C-source-directory isn't set, or if it's set to a directory that contains source to a different Emacs version, just return nil from helpful--definition.
-rw-r--r--CHANGELOG.md2
-rw-r--r--helpful.el9
2 files changed, 9 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 11dfdab..22851a9 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -3,6 +3,8 @@
Fixed a crash on functions defined in a .elc when the .el file is not
available.
+Fixed some crashes on primitive functions.
+
Better handling of docstrings:
* All strings in quotes are highlighted. For example, previously
diff --git a/helpful.el b/helpful.el
index 711bb7f..640d408 100644
--- a/helpful.el
+++ b/helpful.el
@@ -790,7 +790,7 @@ buffer."
;; `base-sym' is the underlying symbol if `sym' is an alias.
(setq sym base-sym)
(setq path src-path)))
- (when (and primitive-p path)
+ (when (and primitive-p path find-function-C-source-directory)
;; Convert "src/foo.c" to "".
(setq path (f-expand path
(f-parent find-function-C-source-directory))))
@@ -849,7 +849,12 @@ buffer."
(-let [(sym-buf . sym-pos) (find-definition-noselect sym 'defvar)]
(setq buf sym-buf)
(setq pos sym-pos))
- (search-failed nil))))
+ (search-failed nil)
+ ;; If your current Emacs instance doesn't match the source
+ ;; code configured in find-function-C-source-directory, we can
+ ;; get an error about not finding source. Try
+ ;; `default-tab-width' against Emacs trunk.
+ (error nil))))
(list buf pos opened)))
(defun helpful--source-path (sym callable-p)