commit ffc16a64b2d594b713580194558cf997c3e5ebad
parent b968411f42a8f923e80d609d4219d3d7362a2d03
Author: Wilfred Hughes <me@wilfred.me.uk>
Date: Sat, 20 Jan 2018 11:22:12 +0000
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.
Diffstat:
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git 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
@@ -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)