emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master eef07a5 44/66: Support template functions in company-clang


From: Dmitry Gutov
Subject: [elpa] master eef07a5 44/66: Support template functions in company-clang annotations
Date: Tue, 13 Jan 2015 02:45:00 +0000

branch: master
commit eef07a5dda89d7af9f9d2838e8f773966b6d46c7
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>

    Support template functions in company-clang annotations
    
    Fixes #271
---
 company-clang.el    |    8 +++++++-
 test/clang-tests.el |   14 ++++++++++++++
 2 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/company-clang.el b/company-clang.el
index f30bf14..459056d 100644
--- a/company-clang.el
+++ b/company-clang.el
@@ -150,7 +150,13 @@ or automatically through a custom 
`company-clang-prefix-guesser'."
      ((string-match "[^:]:[^:]" meta)
       (substring meta (1+ (match-beginning 0))))
      ((string-match "\\((.*)[ a-z]*\\'\\)" meta)
-      (match-string 1 meta)))))
+      (let ((paren (match-beginning 1)))
+        (if (not (eq (aref meta (1- paren)) ?>))
+            (match-string 1 meta)
+          (with-temp-buffer
+            (insert meta)
+            (goto-char paren)
+            (substring meta (1- (search-backward "<"))))))))))
 
 (defun company-clang--strip-formatting (text)
   (replace-regexp-in-string
diff --git a/test/clang-tests.el b/test/clang-tests.el
index 4d23a29..c8c03b7 100644
--- a/test/clang-tests.el
+++ b/test/clang-tests.el
@@ -9,3 +9,17 @@
       (should (equal "createBookWithTitle:arg0 andAuthor:arg1" 
(buffer-string)))
       (should (looking-at "arg0"))
       (should (null (overlay-get (company-template-field-at) 'display))))))
+
+(ert-deftest company-clang-simple-annotation ()
+  (let ((str (propertize
+              "foo" 'meta
+              "wchar_t * wmemchr(wchar_t *__p, wchar_t __c, size_t __n)")))
+    (should (equal (company-clang 'annotation str)
+                   "(wchar_t *__p, wchar_t __c, size_t __n)"))))
+
+(ert-deftest company-clang-generic-annotation ()
+  (let ((str (propertize
+              "foo" 'meta
+              "shared_ptr<_Tp> make_shared<typename _Tp>(_Args &&__args...)")))
+    (should (equal (company-clang 'annotation str)
+                   "<typename _Tp>(_Args &&__args...)"))))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]