Git Product home page Git Product logo

drupal-mode's Introduction

Me wearing the @reload code sprinter t-shirt and listening to L.O.C. while hacking on #1921544 at Drupalcon Prague 2013. Photo by Amazee Labs under https://creativecommons.org/licenses/by-nc-sa/2.0/.

drupal-mode's People

Contributors

arnested avatar joddie avatar kaaresl avatar skangas avatar spaceotter avatar xendk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

drupal-mode's Issues

Drupal 8 detection

Drupal-mode doesn't seem to detect Drupal 8, and I believe it used to?

Drupal-mode adds drupal-phpcs to all supported modes.

As in topic.

I got `drupal-mode' installed from ELPA and not enabled by default (autoloads only).

This is wrong behavior. When I open JavaScript file with js2-mode I get a bunch of drupal-phpcs errors.
They should be visible only when drupal-mode is enabled in current buffer.

phpcs with several available Drupal* standards

Problem

drupal/phpcs-standard picks the first available standard matching Drupal.*, so having DrupalPractice installed in tandem with Drupal (coder.module) causes the first to be selected and you loose all rules provided by Drupal.

Suggested solution

One of the following:

  • Provide all standards using phpcs --standard=Drupal,DrupalPractice (Yes, it's possible to provide several).
  • Extract the available standards as a configuration letting the user select which to use.

hook_whatever()

Add someway to create hooks.

  • Look up module name to create the right name of the hook function
  • Can we lookup the parameters for the function? etags? some_module.api.php?
  • Make correct documentation, see also #5

Improved `drupal-insert-function' et al

drupal-insert-function and drupal-insert-hook should not insert function skeleton if the function/hook is already defined elsewhere. or at least warn you.

Flycheck errors with drupal-mode

Something odd has happened in the last few days, hard to pin down exactly when it started - but there have been updates to php mode, drupal-mode, and flycheck mode.

First of all, if I open a Drupal 6 file example.module, Drupal mode isn't set. If I do M-x drupal-mode I get this error:

Debugger entered--Lisp error: (void-function flycheck-set-checker-properties)
  flycheck-set-checker-properties(drupal-phpcs ((flycheck-documentation . "Check non-PHP Drupal files using PHP_CodeSniffer.\n\nThe Drupal standard includes checks for non-PHP files, this\nchecker runs those.\n\nSee URL `http://pear.php.net/package/PHP_CodeSniffer/'.") (flycheck-executable-var . flycheck-drupal-phpcs-executable) (flycheck-command "phpcs" "--report=emacs" (option "--standard=" flycheck-phpcs-standard concat) source-inplace) (flycheck-error-parser . flycheck-parse-with-patterns) (flycheck-error-patterns ("^\\(?1:.+?\\):\\(?2:[[:digit:]]+\\):\\(?3:[[:digit:]]+\\): error - \\(?4:.+\\)$" . error) ("^\\(?1:.+?\\):\\(?2:[[:digit:]]+\\):\\(?3:[[:digit:]]+\\): warning - \\(?4:.+\\)$" . warning)) (flycheck-error-filter . flycheck-sanitize-errors) (flycheck-modes) (flycheck-predicate . #[nil "\303\304\305� \n#\"\207" [drupal-css-modes drupal-js-modes drupal-info-modes apply derived-mode-p append] 6]) (flycheck-next-checkers) (flycheck-file . "/home/kosta/.emacs.d/elpa/drupal-mode-20141116.515/drupal/flycheck.el")))
  byte-code("\306\307\310\"\210\311\312\313\314\315\316\317\320\321\322&    \210\323\312!\210\324\325\326\327\330\331\332B\333\334\335B\336\337\340B\341\342\343 B\257\n\"\210\344\345\325\322#\210\346�    \n#�\347 \313�\211�\203p

If I open index.php in the docroot of a Drupal 7 site, Drupal mode is set, but I get this error:

Debugger entered--Lisp error: (void-function flycheck-set-checker-properties)
  flycheck-set-checker-properties(drupal-phpcs ((flycheck-documentation . "Check non-PHP Drupal files using PHP_CodeSniffer.\n\nThe Drupal standard includes checks for non-PHP files, this\nchecker runs those.\n\nSee URL `http://pear.php.net/package/PHP_CodeSniffer/'.") (flycheck-executable-var . flycheck-drupal-phpcs-executable) (flycheck-command "phpcs" "--report=emacs" (option "--standard=" flycheck-phpcs-standard concat) source-inplace) (flycheck-error-parser . flycheck-parse-with-patterns) (flycheck-error-patterns ("^\\(?1:.+?\\):\\(?2:[[:digit:]]+\\):\\(?3:[[:digit:]]+\\): error - \\(?4:.+\\)$" . error) ("^\\(?1:.+?\\):\\(?2:[[:digit:]]+\\):\\(?3:[[:digit:]]+\\): warning - \\(?4:.+\\)$" . warning)) (flycheck-error-filter . flycheck-sanitize-errors) (flycheck-modes) (flycheck-predicate . #[nil "\303\304\305� \n#\"\207" [drupal-css-modes drupal-js-modes drupal-info-modes apply derived-mode-p append] 6]) (flycheck-next-checkers) (flycheck-file . "/home/kosta/.emacs.d/elpa/drupal-mode-20141116.515/drupal/flycheck.el")))
  byte-code("\306\307\310\"\210\311\312\313\314\315\316\317\320\321\322&    \210\323\312!\210\324\325\326\327\330\331\332B\333\334\335B\336\337\340B\341\342\343 B\257\n\"\210\344\345\325\322#\210\346�    \n#�\347 \313�\211�\203p

Any ideas?

Eldoc-mode fails with gtags/ggtags

This might be a support request or a bug report, but I can't get the eldoc-documentation-function to point to drupal-eldoc-documentation-function due to this failed test in drupal-mode.el:296

    (when (and drupal-get-function-args
               (fboundp 'eldoc-mode))

Now, ggtags.el for sure sets drupal-get-function-args to drupal/ggtags-get-function-args. I've verified this by examining the variable in the buffer after drupal-mode is loaded, so there is something wrong in the execution order here: The test for drupal-get-function-args is run before ggtags.el's drupal-mode-hook, so eldoc-mode isn't enabled.

So now comes the support request / bug: How can I make ggtags.el's set the value for drupal-get-function-args before the test for eldoc-mode? Is there a trick I can use in my .emacs?

Otherwise, thanks for very nice drupal-mode in emacs. It's by far better than anything else I've tested out there.

Cannot open load file: no such file or directory, gtags

Reproduction recipe:
With Emacs 24.5, the following ~/.emacs.d/init.el file and no other files in ~/.emacs.d directory:

;;; ~/.emacs.d/init.el
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
(package-initialize)
    1. start emacs
    1. M-x package-install RET helm-gtags RET
    1. M-x package-install RET drupal-mode RET
    1. restart emacs
    1. M-: (require 'helm-gtags)
    1. M-: (require 'drupal-mode)

Result: An error with this backtrace:

Debugger entered--Lisp error: (file-error "Cannot open load file" "no such file or directory" "gtags")
  require(gtags)
  eval-buffer(#<buffer  *load*> nil "/home/bar/.emacs.d/elpa/drupal-mode-20150830.1227/drupal/gtags.el" nil t)  ; Reading at buffer position 916
  load-with-code-conversion("/home/bar/.emacs.d/elpa/drupal-mode-20150830.1227/drupal/gtags.el" "/home/bar/.emacs.d/elpa/drupal-mode-20150830.1227/drupal/gtags.el" nil t)
  require(drupal/gtags)
  #[nil "\300\301!\207" [require drupal/gtags] 2]()
  eval-after-load(helm-gtags #[nil "\300\301!\207" [require drupal/gtags] 2])
  byte-code("\306�  \n�\f%\307�\211�.\2031

I also get the error "Cannot open load file: no such file or directory, gtags" (without the backtrace) when opening a directory with Dired (e.g. via C-x d).

Drupal.org documentation heads up

I've recently rewritten the book pages about Emacs on drupal.org, and provided an example installation using this mode. It is currently in need of technical overview and it would be helpful if you could take a look at it.

https://www.drupal.org/node/2327741

The overall idea of the Emacs section is to document each take on Drupal modes individually and for this particular solution I've chosen to provide an example installation that utilizes many cool parts of it, rather than document every aspect of it.

`drupal-detect-drupal-version' also outside full projects

drupal-detect-drupal-version' will only detect adrupal-version' and go into `drupal-mode' if the visited file is part of a full Drupal project.

It should also detect i.e. files that are just part of a module or theme (if i.e. you have only made git clone of a single module).

I guess the will be useful to developers that not only work on building sites but also developers who are i.e. module maintainers.

`drupal-version' can be detected from module.info file.

`drupal-root' should be set to nil.

Maybe also set a `drupal-module-name' on the module folder - this could also be done in full projects and be helpful for other functions.

Javascript mode support

Support javascript major modes in the same way we support php-mode (Drupal style indentation, etc.)

Send selected text to `drush php-eval`

I'm new to the Emacs world so I don't think I will be able to contribute this feature myself. However it would be nice if one had the ability to select a block of text and run a command (drush-php-eval) to pipe that text to drush -r DRUPAL_ROOT php-eval, then display the results in a buffer.

Eshell pccomplete support for drush

Hi, I just read this great post on getting Eshell's pccomplete working with git:

http://tsdh.wordpress.com/2013/05/31/eshell-completion-for-git-bzr-and-hg/

It seem like it would be great to add this same support for drush in Eshell. Drush already works great for me in Eshell with the exception that I haven't been able to display ansi colors.

It seems that it would be easy at drupal-mode init to run 'drush help' and then store the various options in pcmpl-git-commands.

I might try to take a stab at this with my rudimentary elisp, but it seems like this autocompletion of drush should be available to all emacs Drupal folks.

Async cache clear

Hi @arnested,

how do you feel about using async-shell-command for drupal-drush-cache-clear () instead of call-process? On some sites I work on, clearing the cache can take upwards of a minute, which is a long time for Emacs to be locked up.

Kosta

Drush support

Run drush commands from within emacs.

Can we do fancy completion on drush commands and arguments without hitting a performance penalty by invoking drush a lot?

Drupal jargon spell checking

Create a dictionary of Drupal specific words and add the follwing to drupal/ispell.el:

(when ispell-really-aspell
  (add-to-list (make-local-variable 'ispell-extra-args)
               '("--extra-dicts" "some_dict_with_drupal_jargon")))

Would enable aspell users to have better spell checking in comments and strings.

symbol's value as variable is void: gtags-auto-update

Looks like a recent commit introduced a bug.
gtags-auto-update is being accessed when it isn't defined, causing an error: "symbol's value as variable is void: gtags-auto-update".

Backtrace:

Debugger entered--Lisp error: (void-variable gtags-auto-update)
  (if (boundp (quote gtags-auto-update)) nil gtags-auto-update)
  (unless (boundp (quote gtags-auto-update)) gtags-auto-update)
  (and (unless (boundp (quote gtags-auto-update)) gtags-auto-update) drupal-drush-program (zerop (call-process drupal-drush-program nil nil nil "help" "etags")))
  eval((and (unless (boundp (quote gtags-auto-update)) gtags-auto-update) drupal-drush-program (zerop (call-process drupal-drush-program nil nil nil "help" "etags"))))
  byte-code("\303�\304N\211�\203�

Original issue reported in Spacemacs: syl20bnr/spacemacs#2153

CSS mode support

Support CSS major modes in the same way we support php-mode (Drupal style indentation, etc.)

Detect codesniffer installed via coder module

Detect drupal codesniffer installed via coder module.

Coder module could be installed in ~/.drush or as part of a project.

If installed via a project our detection should only be valid for that project (currently we detect drupal codesniffer ones for the entire emacs session).

Indentation using 4 spaces instead of 2

If I open up a Drupal module file, php-mode and drupal-mode are active, but indentation defaults to 4 spaces instead of 2. Do you have ideas on what might be the issue or how I could debug the problem? (My .emacs.d is here if that helps you identify what might be the issue.)

drush aliases

Support drush aliases:

  • Undestand the syntax and parse out relevant info about a site (i.e. the root)
  • Set current site and apply it to all drush commands (similar to doing drush use @mysite but with the side effect that Emacs will now also know more about the site)

Drupal/flycheck error

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'.

Access protection keywords in class methods confuse indentation

Given a class method like the following:

  public function foo() {
           // indent comes to here, two spaces past the beginning of 'function'.

It seems that public/private/protected keywords should be easily ignored as php-mode.el contains the code:

(c-lang-defconst c-protection-kwds
  "Access protection label keywords in classes."
  php '("private" "protected" "public"))

Is this just me, or are others seeing this, too?

Any ideas? (BTW: the rest of the package is so awesome I use it anyway...)

Running all the latest emacs and packages on Arch GNU/Linux.

wrong type argument in drupal-convert-line-ending

Backtrace:
https://gist.github.com/dhaley/5851985

Hi in the defun, drupal-convert-line-ending, the function /= is sometimes passes a non-numeric value triggering a backtrace.

In my drupal buffer, evaluating (coding-system-eol-type buffer-file-coding-system), returns:

[utf-8-unix utf-8-dos utf-8-mac]

The HELP for coding-system-eol-type says that, "A vector value indicates that a format of end-of-line should be detected automatically. Nth element of the vector is the subsidiary
coding system whose eol-type is N."

I think I have a patch for the issue.

Suppressing drupal-mode

Working on a PSR-2 composer project that's installed inside a Drupal root has proven painful. Whenever one opens another class file (which there's usually many in composer projects) makes flycheck (and I guess flymake) wine all over the buffer, and indentation is all wrong. Disabling drupal-mode and resetting all the relevant local variables is... A challenge.

When D8 lands, the issue is going to become bigger, as it's going to pull on more non-Drupal libs into vendor/.

@arnested what's your thoughts on the possibility of drupal-mode being able to restore everything it fiddled with when being disabled? My hunch is that it's a losing battle, even if drupal-mode made a note of everything and carefully restored the original values, there's always the possibility of some other lisp code reacting to things drupal-mode has touched...

So my gut feeling is that working on not enabling drupal-mode for non-Drupal files in the fist place is the way forward. The question is what the heuristics should be.

One easy thing would to add a hook-call or something around https://github.com/arnested/drupal-mode/blob/develop/drupal-mode.el#L848 that would allow one to tell drupal-mode if it should fire or not. Even, perhaps, ask the user if it seems a tossup. A default implementation that asks the user if the current file lies somewhere below a vendor dir might actually be a decent compromise for an alpha implementation.

Or, we could just assume that everything under vendor is not Drupal code, and leave it up to whatever the user has configured Emacs to per default. Might actually be the sensible way to deal with it.

Tail drupal_debug.txt

Tail a drupal_debug.txt file with 'auto-revert-tail-mode' in "debug window".

Could be useful for tracking debug information from dd() and friends.

Setting c-default-style to a string causes error.

Following the guide here https://www.emacswiki.org/emacs/IndentingC I set the c-default-style to "linux" which causes an error because of a bug in drupal-mode.

Debugger entered--Lisp error: (wrong-type-argument listp "linux")
  cc-choose-style-for-mode(c-mode ((drupal-mode . "drupal") . "linux"))
  c-basic-common-init(c-mode ((drupal-mode . "drupal") . "linux"))
  c-common-init(c-mode)
  c-mode()
  set-auto-mode-0(c-mode nil)
  set-auto-mode()
  normal-mode(t)
  after-find-file(nil t)
  find-file-noselect-1(#<buffer main.c<017>> "~/work/projects/the-c-programming-language/c1/017/main.c" nil nil "~/work/projects/the-c-programming-language/c1/017/main.c" (6816699 2052))
  find-file-noselect("/home/ico/work/projects/the-c-programming-language/c1/017/main.c" nil nil nil)
  find-file("/home/ico/work/projects/the-c-programming-language/c1/017/main.c")
  dired-find-file()
  call-interactively(dired-find-file nil nil)
  command-execute(dired-find-file)

Doxygen comments

Support writing Doxygen comments (well the Drupal subset of it at least).

Someone somewhere must have done this already?

Look at what can be done with `c-doc-comment-style'.

Latest version fails.

The ae4dd40 commit fails when installing via MELPA.

Starting Emacs afterwards results in a

Warning (initialization): An error occurred while loading `/home/xen/.emacs.d/init.el':

Wrong type argument: stringp, nil

To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file.  Start Emacs with
the `--debug-init' option to view a complete error backtrace.

After enabling the debugger, I get this when installing the package:

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  call-process(nil nil t nil "--early=includes/complete.inc")
  (progn (call-process drupal-drush-program nil t nil "--early=includes/complete.inc") (goto-char 0) (let (commands) (while (re-search-forward "^[[:blank:]]*\\([@]?[[:word:]-.]+\\)" nil t) (setq commands (cons (match-string-no-properties 1) commands))) (sort commands (function string<))))
  (unwind-protect (progn (call-process drupal-drush-program nil t nil "--early=includes/complete.inc") (goto-char 0) (let (commands) (while (re-search-forward "^[[:blank:]]*\\([@]?[[:word:]-.]+\\)" nil t) (setq commands (cons (match-string-no-properties 1) commands))) (sort commands (function string<)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process drupal-drush-program nil t nil "--early=includes/complete.inc") (goto-char 0) (let (commands) (while (re-search-forward "^[[:blank:]]*\\([@]?[[:word:]-.]+\\)" nil t) (setq commands (cons (match-string-no-properties 1) commands))) (sort commands (function string<)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer))))
  (let ((temp-buffer (generate-new-buffer " *temp*"))) (save-current-buffer (set-buffer temp-buffer) (unwind-protect (progn (call-process drupal-drush-program nil t nil "--early=includes/complete.inc") (goto-char 0) (let (commands) (while (re-search-forward "^[[:blank:]]*\\([@]?[[:word:]-.]+\\)" nil t) (setq commands (cons ... commands))) (sort commands (function string<)))) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))))
  drupal/pcomplete-drush-commands()
  (defvar drupal/pcomplete-drush-commands (drupal/pcomplete-drush-commands) "List of `drush' commands.")
  eval-buffer(#<buffer  *load*-506106> nil "/home/xen/.emacs.d/elpa/drupal-mode-20130602.2146/drupal/pcomplete.el" nil t)  ; Reading at buffer position 1485
  load-with-code-conversion("/home/xen/.emacs.d/elpa/drupal-mode-20130602.2146/drupal/pcomplete.el" "/home/xen/.emacs.d/elpa/drupal-mode-20130602.2146/drupal/pcomplete.el" nil t)
  require(drupal/pcomplete)
  (lambda nil (require (quote drupal/pcomplete)))()
  funcall((lambda nil (require (quote drupal/pcomplete))))
  eval((funcall (quote (lambda nil (require (quote drupal/pcomplete))))))
  eval-after-load(pcomplete (require (quote drupal/pcomplete)))
  eval-buffer(#<buffer  *load*> nil "/home/xen/.emacs.d/elpa/drupal-mode-20130602.2146/drupal-mode-autoloads.el" nil t)  ; Reading at buffer position 2215
  load-with-code-conversion("/home/xen/.emacs.d/elpa/drupal-mode-20130602.2146/drupal-mode-autoloads.el" "/home/xen/.emacs.d/elpa/drupal-mode-20130602.2146/drupal-mode-autoloads.el" nil t)
  load("/home/xen/.emacs.d/elpa/drupal-mode-20130602.2146/drupal-mode-autoloads" nil t)
  package--make-autoloads-and-compile("drupal-mode" "/home/xen/.emacs.d/elpa/drupal-mode-20130602.2146")
  package-unpack(drupal-mode "20130602.2146")
  package-download-tar(drupal-mode "20130602.2146")
  package-download-transaction((drupal-mode))
  package-install(drupal-mode)
  mapc(package-install (drupal-mode))
  package-menu-execute()
  call-interactively(package-menu-execute nil nil)

Reverting to 6dd8edc and things work again.

Flymake PHPCS/DrupalCS Integration Not Working

Hi there, I was pointed to your drupal-mode by @illusori in this thread.

After a bit of wrestling, I've got PHPCS correctly linting .php files that are not in Drupal mode, but error checking is not working for .module and .php files in Drupal mode (in Drupal project dirs).

I've done a bit of debugging and determined that (a) the flymake_phpcs function is running, and (b) it's returning output. When I run the same command it runs on a given file I get a lot of errors.

Got any ideas why it might be getting so far as to be executing the phpcs command correctly, returning results, but not seeing anything in my editing window?

Thanks for sharing this great tool, it's definitely the most well architected of the options I've seen out there so far, and I'm excited to use it. Btw I also have set up a repo with a bunch of D7 snippets for drupal-mode, if you'd like to incorporate them or link, feel free.

Run test cases

While developing offer a simple way to run a modules test cases (possibly via drush) and view the result.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.