]> code.delx.au - gnu-emacs-elpa/commitdiff
Add company-semantic-insert-arguments
authorDmitry Gutov <dgutov@yandex.ru>
Sun, 17 Jan 2016 11:21:16 +0000 (14:21 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Sun, 17 Jan 2016 11:21:16 +0000 (14:21 +0300)
Closes #448

NEWS.md
company-semantic.el

diff --git a/NEWS.md b/NEWS.md
index 3a22f7e7c75bef430d39a65c6c39e045fd18f403..33750f119d58e4091a79d103d9af03dbb162efea 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,7 @@
 
 ## Next
 
 
 ## 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.
 * `company-semantic-begin-after-member-access`: New option. Similar to the one
   in `company-clang`.
 * `company-capf` accepts `:company-prefix-length` property function.
index 27522da5d95a7c8b2ea1ed3110444faebbdd1c06..8b13b72c6037bcacf186b60cb1ce282f3d077399 100644 (file)
@@ -26,6 +26,7 @@
 ;;; Code:
 
 (require 'company)
 ;;; Code:
 
 (require 'company)
+(require 'company-template)
 (require 'cl-lib)
 
 (defvar semantic-idle-summary-function)
 (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
 \":\".")
 
 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
 (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)
     (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
 
 (provide 'company-semantic)
 ;;; company-semantic.el ends here