[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master b0f206a 020/173: Handle function pointers in annotation an
From: |
Dmitry Gutov |
Subject: |
[elpa] master b0f206a 020/173: Handle function pointers in annotation and template expansion |
Date: |
Thu, 23 Jun 2016 00:28:35 +0000 (UTC) |
branch: master
commit b0f206a2e8deb4c168d7dc989f4516741ae49a8c
Author: Dmitry Gutov <address@hidden>
Commit: Dmitry Gutov <address@hidden>
Handle function pointers in annotation and template expansion
Fixes #322
---
company-clang.el | 12 ++++++++++++
company-template.el | 2 ++
test/clang-tests.el | 4 ++++
test/template-tests.el | 9 +++++++++
4 files changed, 27 insertions(+)
diff --git a/company-clang.el b/company-clang.el
index 4929bad..0c4252e 100644
--- a/company-clang.el
+++ b/company-clang.el
@@ -144,6 +144,18 @@ or automatically through a custom
`company-clang-prefix-guesser'."
(get-text-property 0 'meta candidate))
(defun company-clang--annotation (candidate)
+ (let ((ann (company-clang--annotation-1 candidate)))
+ (if (not (string-prefix-p "(*)" ann))
+ ann
+ (with-temp-buffer
+ (insert ann)
+ (search-backward ")")
+ (let ((pt (1+ (point))))
+ (forward-symbol 1)
+ (delete-region pt (point)))
+ (buffer-string)))))
+
+(defun company-clang--annotation-1 (candidate)
(let ((meta (company-clang--meta candidate)))
(cond
((null meta) nil)
diff --git a/company-template.el b/company-template.el
index 21ae011..2c11217 100644
--- a/company-template.el
+++ b/company-template.el
@@ -169,6 +169,8 @@ Leave point at the end of the field."
(forward-char)
(setq cnt (company-template--c-like-args templ angle-close
cnt))))
+ (when (looking-back "\\((\\*)\\)(" (line-beginning-position))
+ (delete-region (match-beginning 1) (match-end 1)))
(when paren-open
(goto-char paren-open)
(company-template--c-like-args templ paren-close cnt)))
diff --git a/test/clang-tests.el b/test/clang-tests.el
index 09ba114..f2d55cc 100644
--- a/test/clang-tests.el
+++ b/test/clang-tests.el
@@ -44,3 +44,7 @@
"shared_ptr<_Tp> make_shared<typename _Tp>(_Args &&__args...)")))
(should (equal (company-clang 'annotation str)
"<typename _Tp>(_Args &&__args...)"))))
+
+(ert-deftest company-clang-func-ptr-annotation ()
+ (let ((str (propertize "foo" 'meta "void (*)(int) foo")))
+ (should (equal (company-clang 'annotation str) "(*)(int)"))))
diff --git a/test/template-tests.el b/test/template-tests.el
index 09548c4..d589ebd 100644
--- a/test/template-tests.el
+++ b/test/template-tests.el
@@ -89,3 +89,12 @@
(forward-char -1)
(should (equal "Dict<TKey, TValue>"
(overlay-get (company-template-field-at) 'display))))))
+
+(ert-deftest company-template-c-like-func-ptr ()
+ (with-temp-buffer
+ (let ((text "foo(*)(int)"))
+ (insert text)
+ (company-template-c-like-templatify text)
+ (should (equal "foo(arg0)" (buffer-string)))
+ (should (looking-at "arg0"))
+ (should (equal "int" (overlay-get (company-template-field-at)
'display))))))
- [elpa] master dae79c4 002/173: Merge branch 'search-hl-fix', (continued)
- [elpa] master dae79c4 002/173: Merge branch 'search-hl-fix', Dmitry Gutov, 2016/06/22
- [elpa] master 12f55f5 013/173: Buf was unused, Dmitry Gutov, 2016/06/22
- [elpa] master e94f2ec 008/173: company-show-doc-buffer: Still call doc-buffer inside the electric block, Dmitry Gutov, 2016/06/22
- [elpa] master 125a4da 009/173: company-show-location: Mirror the latest change to company-show-doc-buffer, Dmitry Gutov, 2016/06/22
- [elpa] master 7941f6e 010/173: company-diag: Include Emacs and Company versions, Dmitry Gutov, 2016/06/22
- [elpa] master 5733f2b 011/173: company-diag: Fix the annotation call, Dmitry Gutov, 2016/06/22
- [elpa] master af962d4 012/173: company-diag: Call `annotation' in the right buffer, Dmitry Gutov, 2016/06/22
- [elpa] master 5e107fd 015/173: Accept numeric argument in company-select-next and friends, Dmitry Gutov, 2016/06/22
- [elpa] master 479c676 021/173: Don't use `forward-symbol', apparently it's not in 24.3, Dmitry Gutov, 2016/06/22
- [elpa] master 41f4536 018/173: Add missing require to `company-gtags`, Dmitry Gutov, 2016/06/22
- [elpa] master b0f206a 020/173: Handle function pointers in annotation and template expansion,
Dmitry Gutov <=
- [elpa] master d56ddaa 006/173: Allow scrolling the doc window with the mouse wheel, Dmitry Gutov, 2016/06/22
- [elpa] master a7a4ba6 014/173: Merge branch 'release', Dmitry Gutov, 2016/06/22
- [elpa] master 464a458 022/173: company-lighter: dispatch on whether company-candidates is non-nil, Dmitry Gutov, 2016/06/22
- [elpa] master b94b115 025/173: company--insert-candidate: Don't insert an empty string, Dmitry Gutov, 2016/06/22
- [elpa] master decd537 030/173: Add MELPA badge, Dmitry Gutov, 2016/06/22
- [elpa] master 22ecb92 001/173: company-clang--start-process: Disable undo in the output buffer, Dmitry Gutov, 2016/06/22
- [elpa] master 5fe84a2 028/173: Merge pull request #334 from vermiculus/patch-1, Dmitry Gutov, 2016/06/22
- [elpa] master 2de213e 032/173: company-dabbrev--search-buffer: Save match data, Dmitry Gutov, 2016/06/22
- [elpa] master a0ba593 029/173: Drop githalytics link, Dmitry Gutov, 2016/06/22
- [elpa] master 6301093 023/173: Clarify the meaning of cdr in the prefix cons, Dmitry Gutov, 2016/06/22