]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/company/company-template.el
Merge branch 'master' of github.com:leoliu/ggtags
[gnu-emacs-elpa] / packages / company / company-template.el
index 6ffd648f37f298605e3fe1dc857508dd49837922..ea1db86bca7a695711f62b51f0251fb7a7bf673f 100644 (file)
@@ -1,6 +1,6 @@
 ;;; company-template.el
 
-;; Copyright (C) 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2009, 2010, 2013 Free Software Foundation, Inc.
 
 ;; Author: Nikolaj Schumacher
 
@@ -34,6 +34,9 @@
     (define-key keymap [tab] 'company-template-forward-field)
     keymap))
 
+(defvar company-template--buffer-templates nil)
+(make-variable-buffer-local 'company-template--buffer-templates)
+
 ;; interactive ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (defun company-template-templates-at (pos)
@@ -73,9 +76,6 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defvar company-template--buffer-templates nil)
-(make-variable-buffer-local 'company-template--buffer-templates)
-
 (defun company-template-declare-template (beg end)
   (let ((ov (make-overlay beg end)))
     ;; (overlay-put ov 'face 'highlight)
@@ -134,7 +134,7 @@ Leave point at the end of the field."
 
 ;; hooks ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
-(defun company-template-insert-hook (ovl after-p &rest ignore)
+(defun company-template-insert-hook (ovl after-p &rest _ignore)
   "Called when a snippet input prompt is modified."
   (unless after-p
     (company-template-remove-field ovl t)))
@@ -150,6 +150,8 @@ Leave point at the end of the field."
   (let* ((end (point-marker))
          (beg (- (point) (length call)))
          (cnt 0))
+    (when (re-search-backward ")" beg t)
+      (delete-region (match-end 0) end))
     (goto-char beg)
     (when (search-forward "(" end 'move)
       (if (eq (char-after) ?\))