|
| 1 | +;;; drupal/flymake-phpcs.el --- Drupal-mode support for flymake-phpcs |
| 2 | + |
| 3 | +;; Copyright (C) 2012, 2013 Arne Jørgensen |
| 4 | + |
| 5 | +;; Author: Thomas Fini Hansen <[email protected]> |
| 6 | + |
| 7 | +;; This file is part of Drupal mode. |
| 8 | + |
| 9 | +;; Drupal mode is free software: you can redistribute it and/or modify |
| 10 | +;; it under the terms of the GNU General Public License as published |
| 11 | +;; by the Free Software Foundation, either version 3 of the License, |
| 12 | +;; or (at your option) any later version. |
| 13 | + |
| 14 | +;; Drupal mode is distributed in the hope that it will be useful, but |
| 15 | +;; WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | +;; General Public License for more details. |
| 18 | + |
| 19 | +;; You should have received a copy of the GNU General Public License |
| 20 | +;; along with Drupal mode. If not, see <http://www.gnu.org/licenses/>. |
| 21 | + |
| 22 | +;;; Commentary: |
| 23 | + |
| 24 | +;; Enable drupal-mode support for flymake-phpcs. |
| 25 | + |
| 26 | +;;; Code: |
| 27 | + |
| 28 | +(require 'drupal/phpcs) |
| 29 | + |
| 30 | +(defcustom drupal/flycheck-phpcs-dont-show-trailing-whitespace t |
| 31 | + "Non-nil means don't highlight trailing whitespace when flycheck-phpcs is in use. |
| 32 | +Flycheck-phpcs will also highlight trailing whitespace as an error |
| 33 | +so no need to highlight it twice." |
| 34 | + :type `(choice |
| 35 | + (const :tag "Yes" t) |
| 36 | + (const :tag "No" nil)) |
| 37 | + :group 'drupal) |
| 38 | + |
| 39 | +(defun drupal/flycheck-hook () |
| 40 | + "Enable drupal-mode support for flycheck." |
| 41 | + (when (and (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes)) |
| 42 | + (executable-find "phpcs") |
| 43 | + drupal/phpcs-standard) |
| 44 | + ;; Set the coding standard to "Drupal" (we checked that it is |
| 45 | + ;; supported above. |
| 46 | + (set (make-local-variable 'flycheck-phpcs-standard) drupal/phpcs-standard) |
| 47 | + |
| 48 | + ;; Flycheck will also highlight trailing whitespace as an |
| 49 | + ;; error so no need to highlight it twice. |
| 50 | + (when drupal/flycheck-phpcs-dont-show-trailing-whitespace |
| 51 | + (setq show-trailing-whitespace nil)) |
| 52 | + ) |
| 53 | +) |
| 54 | + |
| 55 | +(add-hook 'drupal-mode-hook #'drupal/flycheck-hook) |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +(provide 'drupal/flycheck) |
| 60 | + |
| 61 | +;;; drupal/flycheck.el ends here |
0 commit comments