;;
;; Copyright (C) 2010 Nikolaj Schumacher
;;
-;; This file is part of company 0.4.3.
+;; This file is part of company 0.5.
;;
;; This program is free software; you can redistribute it and/or
;; modify it under the terms of the GNU General Public License
(goto-char (point-min))
(let ((pattern (format company-clang--completion-pattern
(regexp-quote prefix)))
+ (case-fold-search nil)
lines match)
(while (re-search-forward pattern nil t)
(setq match (match-string-no-properties 1))
(1+ (current-column)))))
(defsubst company-clang--build-complete-args (pos)
- (append '("-cc1" "-fsyntax-only")
+ (append '("-cc1" "-fsyntax-only" "-code-completion-macros")
company-clang-arguments
(when (stringp company-clang--prefix)
(list "-include" (expand-file-name company-clang--prefix)))
(when (re-search-forward "\\`clang version \\([0-9.]+\\)" nil t)
(match-string-no-properties 1))))
+(defun company-clang-objc-templatify (selector)
+ (let* ((end (point))
+ (beg (- (point) (length selector)))
+ (templ (company-template-declare-template beg end)))
+ (save-excursion
+ (goto-char beg)
+ (while (search-forward ":" end t)
+ (replace-match ": ")
+ (incf end 2)
+ (company-template-add-field templ (1- (match-end 0)) "<arg>"))
+ (delete-char -1))
+ (company-template-move-to-first templ)))
+
(defun company-clang (command &optional arg &rest ignored)
"A `company-mode' completion back-end for clang.
Clang is a parser for C and ObjC. The unreleased development version of
`company-clang-auto-save' determines whether to do this automatically."
(interactive (list 'interactive))
(case command
- ('interactive (company-begin-backend 'company-clang))
- ('init (unless company-clang-executable
- (error "Company found no clang executable"))
- (when (version< (company-clang-version)
- company-clang-required-version)
- (error "Company requires clang version 1.1")))
- ('prefix (and (memq major-mode company-clang-modes)
- buffer-file-name
- company-clang-executable
- (not (company-in-string-or-comment))
- (or (company-grab-symbol) 'stop)))
- ('candidates (company-clang--candidates arg))))
+ (interactive (company-begin-backend 'company-clang))
+ (init (unless company-clang-executable
+ (error "Company found no clang executable"))
+ (when (version< (company-clang-version)
+ company-clang-required-version)
+ (error "Company requires clang version 1.1")))
+ (prefix (and (memq major-mode company-clang-modes)
+ buffer-file-name
+ company-clang-executable
+ (not (company-in-string-or-comment))
+ (or (company-grab-symbol) 'stop)))
+ (candidates (company-clang--candidates arg))
+ (post-completion (and (derived-mode-p 'objc-mode)
+ (string-match ":" arg)
+ (company-clang-objc-templatify arg)))))
(provide 'company-clang)
;;; company-clang.el ends here