]> code.delx.au - gnu-emacs-elpa/commitdiff
string-prefix-p signals error on nil in Emacs < 25
authorDmitry Gutov <dgutov@yandex.ru>
Wed, 25 Mar 2015 17:11:10 +0000 (19:11 +0200)
committerDmitry Gutov <dgutov@yandex.ru>
Wed, 25 Mar 2015 17:11:10 +0000 (19:11 +0200)
Fixes #332

company-clang.el
test/clang-tests.el

index 79bd5bd2f609ddedf61380157588df29b5680aa0..cc392e4c1085bbcd45512b3984e893b336f0983f 100644 (file)
@@ -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)
index f2d55cc42d53f814cc0225d462c10fe03e6ca37f..abe690b386c1e953d6c0cc3f6c682f6361299a8c 100644 (file)
@@ -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)))))