From: Dmitry Gutov Date: Wed, 20 Mar 2013 21:20:38 +0000 (+0400) Subject: company-clang: Only initialize in supported major modes X-Git-Url: https://code.delx.au/gnu-emacs-elpa/commitdiff_plain/da32a6a4e9fd28006e4a53e99250e80587cb50bf company-clang: Only initialize in supported major modes --- 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