From: Dmitry Gutov Date: Wed, 25 Mar 2015 17:11:10 +0000 (+0200) Subject: string-prefix-p signals error on nil in Emacs < 25 X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/b20726c7b64dafdd10bd3ba44750e9acaad12b6f?hp=b94b115651dbe50a8096d0bc1ec9c7ca5e7570d0 string-prefix-p signals error on nil in Emacs < 25 Fixes #332 --- diff --git a/company-clang.el b/company-clang.el index 79bd5bd2f..cc392e4c1 100644 --- a/company-clang.el +++ b/company-clang.el @@ -145,7 +145,7 @@ or automatically through a custom `company-clang-prefix-guesser'." (defun company-clang--annotation (candidate) (let ((ann (company-clang--annotation-1 candidate))) - (if (not (string-prefix-p "(*)" ann)) + (if (not (and ann (string-prefix-p "(*)" ann))) ann (with-temp-buffer (insert ann) diff --git a/test/clang-tests.el b/test/clang-tests.el index f2d55cc42..abe690b38 100644 --- a/test/clang-tests.el +++ b/test/clang-tests.el @@ -48,3 +48,7 @@ (ert-deftest company-clang-func-ptr-annotation () (let ((str (propertize "foo" 'meta "void (*)(int) foo"))) (should (equal (company-clang 'annotation str) "(*)(int)")))) + +(ert-deftest company-clang-null-annotation () + (let ((str "char")) + (should (null (company-clang 'annotation str)))))