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

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

[elpa] master faa8f84 120/173: Add company-semantic-insert-arguments


From: Dmitry Gutov
Subject: [elpa] master faa8f84 120/173: Add company-semantic-insert-arguments
Date: Thu, 23 Jun 2016 00:28:44 +0000 (UTC)

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

    Add company-semantic-insert-arguments
    
    Closes #448
---
 NEWS.md             |    1 +
 company-semantic.el |   14 +++++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/NEWS.md b/NEWS.md
index 3a22f7e..33750f1 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
 
 ## Next
 
+* `company-semantic-insert-arguments`: New option. Like in `company-clang`.
 * `company-semantic-begin-after-member-access`: New option. Similar to the one
   in `company-clang`.
 * `company-capf` accepts `:company-prefix-length` property function.
diff --git a/company-semantic.el b/company-semantic.el
index 27522da..8b13b72 100644
--- a/company-semantic.el
+++ b/company-semantic.el
@@ -26,6 +26,7 @@
 ;;; Code:
 
 (require 'company)
+(require 'company-template)
 (require 'cl-lib)
 
 (defvar semantic-idle-summary-function)
@@ -57,6 +58,11 @@ If `company-begin-commands' is a list, it should include 
`c-electric-lt-gt'
 and `c-electric-colon', for automatic completion right after \">\" and
 \":\".")
 
+(defcustom company-semantic-insert-arguments t
+  "When non-nil, insert function arguments as a template after completion."
+  :type 'boolean
+  :package-version '(company . "0.9.0"))
+
 (defvar company-semantic-modes '(c-mode c++-mode jde-mode java-mode))
 
 (defvar-local company-semantic--current-tags nil
@@ -149,7 +155,13 @@ and `c-electric-colon', for automatic completion right 
after \">\" and
     (location (let ((tag (assoc arg company-semantic--current-tags)))
                 (when (buffer-live-p (semantic-tag-buffer tag))
                   (cons (semantic-tag-buffer tag)
-                        (semantic-tag-start tag)))))))
+                        (semantic-tag-start tag)))))
+    (post-completion (let ((anno (company-semantic-annotation
+                                  arg company-semantic--current-tags)))
+                       (when (and company-semantic-insert-arguments anno)
+                         (insert anno)
+                         (company-template-c-like-templatify (concat arg 
anno)))
+                       ))))
 
 (provide 'company-semantic)
 ;;; company-semantic.el ends here



reply via email to

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