arnested / drupal-mode

Advanced Emacs minor mode for Drupal development
https://melpa.org/#/drupal-mode
GNU General Public License v3.0
32 stars 14 forks source link

Drupal/flycheck error #38

Closed spaceotter closed 10 years ago

spaceotter commented 10 years ago

Drupal-mode was broken on install. Error like the following:

reference to free variable `css-js-phpcs'

I found the reason to be that flycheck has moved to a different macro. Use 'flycheck-define-checker' and not 'flycheck-declare-checker'.

spaceotter commented 10 years ago

I have been able to clear the error with the following replacement for the call to 'flycheck-declare-checker'.

(flycheck-define-checker css-js-phpcs
  "Check CSS and JavaScript  using PHP_CodeSniffer.

PHP_CodeSniffer can be used to check non-PHP files, as exemplified by the
Drupal code sniffer.

See URL `http://pear.php.net/package/PHP_CodeSniffer/'."
  :command ("phpcs" "--report=emacs"
             (option "--standard=" flycheck-phpcs-standard)
             source)
  ;; Though phpcs supports Checkstyle output which we could feed to
  ;; `flycheck-parse-checkstyle', we are still using error patterns here,
  ;; because PHP has notoriously unstable output habits.  See URL
  ;; `https://github.com/lunaryorn/flycheck/issues/78' and URL
  ;; `https://github.com/lunaryorn/flycheck/issues/118'
  :error-patterns
  ((error "\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): error - \\(?4:.*\\)")
    (warning "\\(?1:.*\\):\\(?2:[0-9]+\\):\\(?3:[0-9]+\\): warning - \\(?4:.*\\)"))
  :modes (css-mode js-mode)
  :predicate (lambda ()
               (and drupal/flycheck-phpcs-js-and-css (apply 'derived-mode-p (append drupal-php-modes drupal-css-modes drupal-js-modes)))))
arnested commented 10 years ago

Thank you. I don't use flycheck myself (yet) so please let me know if this causes any problems.

@xendk might want to test it out?

xendk commented 10 years ago

After upgrading flycheck and PHPMD which flycheck now supports (which we'll probably want to configure specially for Drupal mode buffers), it seems to work. Haven't done any serious testing thought.