X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/f45b11ea6e65872ae5c42cff56203dd72247cde5..d97c98fed8fb5e6a03804d96031591e9c433cf58:/company-template.el diff --git a/company-template.el b/company-template.el index 9c42545c0..02065afaf 100644 --- a/company-template.el +++ b/company-template.el @@ -1,4 +1,4 @@ -;;; company-template.el +;;; company-template.el --- utility library for template expansion ;; Copyright (C) 2009, 2010, 2014-2015 Free Software Foundation, Inc. @@ -183,5 +183,32 @@ Leave point at the end of the field." (skip-chars-forward " ") (setq last-pos (point)))))) +;; objc ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +(defun company-clang-objc-templatify (selector) + (let* ((end (point-marker)) + (beg (- (point) (length selector) 1)) + (templ (company-template-declare-template beg end)) + (cnt 0)) + (save-excursion + (goto-char beg) + (catch 'stop + (while (search-forward ":" end t) + (if (looking-at "\\(([^)]*)\\) ?") + (company-template-add-field templ (point) (match-end 1)) + ;; Not sure which conditions this case manifests under, but + ;; apparently it did before, when I wrote the first test for this + ;; function. FIXME: Revisit it. + (company-template-add-field templ (point) + (progn + (insert (format "arg%d" cnt)) + (point))) + (when (< (point) end) + (insert " ")) + (cl-incf cnt)) + (when (>= (point) end) + (throw 'stop t))))) + (company-template-move-to-first templ))) + (provide 'company-template) ;;; company-template.el ends here