From b20726c7b64dafdd10bd3ba44750e9acaad12b6f Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Wed, 25 Mar 2015 19:11:10 +0200 Subject: [PATCH] string-prefix-p signals error on nil in Emacs < 25 Fixes #332 --- company-clang.el | 2 +- test/clang-tests.el | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) 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))))) -- 2.39.2