diff options
| author | Wilfred Hughes <me@wilfred.me.uk> | 2018-01-20 11:22:12 +0000 |
|---|---|---|
| committer | Wilfred Hughes <me@wilfred.me.uk> | 2018-01-20 11:22:12 +0000 |
| commit | ffc16a64b2d594b713580194558cf997c3e5ebad (patch) | |
| tree | 5ed8b41a8eb8532084d4599f2e0c930dd0e32534 | |
| parent | b968411f42a8f923e80d609d4219d3d7362a2d03 (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.md | 2 | ||||
| -rw-r--r-- | helpful.el | 9 |
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 @@ -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) |
