From e1f12f424a2f1701fa9b1fcc974e75c0f224cfa3 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Thu, 28 Sep 2017 18:42:19 +0200 Subject: Transfer chromium rules from stark to blue --- emacs-blue | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/emacs-blue b/emacs-blue index 71386de..d8a7e93 100644 --- a/emacs-blue +++ b/emacs-blue @@ -231,9 +231,18 @@ '("common c" (c-basic-offset . 2))) +(defun get-base-dir (path needle) + "Get base directory for PATH using NEEDLE to cut." + (let ((parts (split-string path "/" t))) + (let ((index (cl-position needle parts :from-end t :test 'equal))) + (if index + (concat "/" (mapconcat 'identity (seq-take parts (+ index 1)) "/")) + path)))) + (make-variable-buffer-local 'flycheck-clang-definitions) (make-variable-buffer-local 'flycheck-clang-include-path) (make-variable-buffer-local 'flycheck-clang-language-standard) +(make-variable-buffer-local 'flycheck-clang-warnings) (add-hook 'c++-mode-hook (lambda() @@ -270,7 +279,36 @@ "/usr/lib/glib-2.0/include" "../subprojects/googletest-release-1.8.0/googletest/include" "../subprojects/googletest-release-1.8.0/googlemock/include" - ))))) + ))) + ;; Chromium hook + (when (and buffer-file-name + (string-match "/chromium/src/" buffer-file-name)) + (let ((base (get-base-dir (file-name-directory buffer-file-name) "src"))) + (make-local-variable 'flycheck-clang-language-standard) + (make-local-variable 'flycheck-clang-include-path) + (setq flycheck-clang-language-standard "c++11" + flycheck-clang-definitions (list "OS_ANDROID") + flycheck-clang-warnings (list "no-unused-parameter") + flycheck-clang-include-path (list base + (concat base "/out_gradle/BetaArm7Debug/gen") + (concat base "/out_gradle/BetaArm7Release/gen")))) + (require 'google-c-style) + (c-add-style "Google" google-c-style t)) + ;; ofa hook + (when (and buffer-file-name + (string-match "/mobile/mobile/" buffer-file-name)) + (let ((base (get-base-dir (file-name-directory buffer-file-name) "mobile"))) + (make-local-variable 'flycheck-clang-language-standard) + (make-local-variable 'flycheck-clang-definitions) + (make-local-variable 'flycheck-clang-include-path) + (setq flycheck-clang-language-standard "c++11" + flycheck-clang-definitions (list "OS_ANDROID") + flycheck-clang-warnings (list "no-unused-parameter") + flycheck-clang-include-path (list base (concat base "/../../chromium/src") + (concat base "/../../chromium/src/out_gradle/BetaArm7Debug/gen") + (concat base "/../../chromium/src/out_gradle/BetaArm7Release/gen")))) + (require 'google-c-style) + (c-add-style "Google" google-c-style t)))) ;; Opera Java hook (add-hook 'java-mode-hook -- cgit v1.2.3-70-g09d2