From 1f30a34741c61f35b18d66b6b506bc2a8242f858 Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Thu, 21 Mar 2013 21:10:08 +0400 Subject: [PATCH 1/1] Add experimental backend command 'common --- NEWS.md | 1 + company-clang.el | 3 +++ company.el | 8 +++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index de36cbde3..0be44ad7e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,7 @@ ## Next +* `company-clang` ObjC arguments template insertion now requires explicit user action. * `company-clang-objc-templatify` does not insert spaces after colons anymore. * `company-clang` is now only initialized in supported buffers. So, no error messages if you don't have Clang until you open a C file. diff --git a/company-clang.el b/company-clang.el index 7fc66a93b..6135f24d0 100644 --- a/company-clang.el +++ b/company-clang.el @@ -239,6 +239,9 @@ Completions only work correctly when the buffer has been saved. "#]" " " (replace-regexp-in-string "[<{[]#\\|#[>}]" "" meta t) t)))) + (common (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))))) diff --git a/company.el b/company.el index df758e10e..fe87eed69 100644 --- a/company.el +++ b/company.el @@ -787,7 +787,9 @@ can retrieve meta-data for them." (push (cons company-prefix company-candidates) company-candidates-cache) ;; Calculate common. (let ((completion-ignore-case (company-call-backend 'ignore-case))) - (setq company-common (try-completion company-prefix company-candidates))) + (let ((common (try-completion company-prefix company-candidates))) + (setq company-common (or (company-call-backend 'common common) + common)))) (when (eq company-common t) (setq company-candidates nil))) @@ -823,9 +825,9 @@ can retrieve meta-data for them." (or (cdr candidates) (not (eq t (compare-strings (car candidates) nil nil prefix nil nil ignore-case))))) - ;; Don't start when already completed and unique. candidates - ;; Not the right place? maybe when setting? + ;; Already completed and unique; don't start. + ;; FIXME: Not the right place? maybe when setting? (and company-candidates t)))) (defun company-idle-begin (buf win tick pos) -- 2.39.2