]> code.delx.au - gnu-emacs-elpa/blobdiff - company-clang.el
company-template-c-like-templatify: use "argN" as actual field text
[gnu-emacs-elpa] / company-clang.el
index 60e29c1694c15a96812c47bbfadf3375a55ce37f..954b9be5c6589b516d69a1f59bc72380c65cac42 100644 (file)
@@ -208,22 +208,18 @@ Prefix files (-include ...) can be selected with
       0)))
 
 (defun company-clang-objc-templatify (selector)
-  (let* ((end (point))
+  (let* ((end (point-marker))
          (beg (- (point) (length selector)))
          (templ (company-template-declare-template beg end))
          (cnt 0))
     (save-excursion
       (goto-char beg)
-      (while (search-forward ":" end t)
-        (let* ((name (format "arg%d" cnt))
-               (len (length name)))
-          (incf end len)
-          (let ((pt (point)))
-            (insert name)
-            (company-template-add-field templ pt (point)))
-          (when (< (point) end)
-            (insert " ")
-            (incf end))
+      (catch 'stop
+        (while (search-forward ":" end t)
+          (company-template-add-field templ (point) (format "arg%d" cnt))
+          (if (< (point) end)
+              (insert " ")
+            (throw 'stop t))
           (incf cnt))))
     (company-template-move-to-first templ)))