;;; Code:
(require 'company)
+(require 'company-template)
(eval-when-compile (require 'cl))
(defcustom company-clang-executable
(defun company-clang-objc-templatify (selector)
(let* ((end (point))
(beg (- (point) (length selector)))
- (templ (company-template-declare-template beg end)))
+ (templ (company-template-declare-template beg end))
+ (cnt 0))
(save-excursion
(goto-char beg)
(while (search-forward ":" end t)
- (replace-match ": ")
- (incf end)
- (company-template-add-field templ (1- (match-end 0)) "<arg>"))
- (delete-char -1))
+ (let* ((name (format "arg%d" cnt))
+ (len (length name)))
+ (incf end len)
+ (company-template-add-field templ (match-end 0) name)
+ (goto-char (+ (match-end 0) len))
+ (when (< (point) end)
+ (insert " ")
+ (incf end))
+ (incf cnt))))
(company-template-move-to-first templ)))
(defun company-clang (command &optional arg &rest ignored)
"#]" " "
(replace-regexp-in-string "[<{[]#\\|#[>}]" "" meta t)
t))))
+ (crop (and (derived-mode-p 'objc-mode)
+ (string-match ":" arg)
+ (substring arg 0 (match-beginning 0))))
(post-completion (and (derived-mode-p 'objc-mode)
(string-match ":" arg)
(company-clang-objc-templatify arg)))))