From da32a6a4e9fd28006e4a53e99250e80587cb50bf Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Thu, 21 Mar 2013 01:20:38 +0400 Subject: [PATCH] company-clang: Only initialize in supported major modes --- NEWS.md | 2 ++ company-clang.el | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 1e562ff31..a14f6058f 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,8 @@ ## Next +* `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. * `company-clang` recognizes Clang included with recent Xcode. * New commands `company-select-previous-or-abort` and `company-select-next-or-abort`, bound to `` and ``. diff --git a/company-clang.el b/company-clang.el index 7c3a3b47f..6b80ef02f 100644 --- a/company-clang.el +++ b/company-clang.el @@ -222,10 +222,11 @@ Completions only work correctly when the buffer has been saved. (interactive (list 'interactive)) (case command (interactive (company-begin-backend 'company-clang)) - (init (unless company-clang-executable - (error "Company found no clang executable")) - (when (< (company-clang-version) company-clang-required-version) - (error "Company requires clang version 1.1"))) + (init (when (memq major-mode company-clang-modes) + (unless company-clang-executable + (error "Company found no clang executable")) + (when (< (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 -- 2.39.2