Skip to content

Latest commit

 

History

History
153 lines (118 loc) · 9.02 KB

README.org

File metadata and controls

153 lines (118 loc) · 9.02 KB

Synopsis

Projectile Drupal is a minor mode for working with the Drupal 7 projects in GNU Emacs. Internally it based on Projectile.

It means that you can use Projectile’s commands for greping (or acking) files, run tests, switch between projects, etc. It’s a great way to navigate a Drupal multi-site or dslm based site file structure.

With Projectile Drupal you are able to:

  • navigate through drupal resources (modules, themes, profiles and so on)
  • have project environment variables available in emacs shells such as eshell
  • run drush –uli

This minor mode is also meant as a companion mode to the minor mode drupal-mode, which is the mode you’ll want to actually edit drupal php files. It does not attempt to duplicate any of the functionality found in drupal-mode or php-mode.

Setup

Prerequisites

This package requires at least emacs 24.3 because of the use of setq-local.

Installation

Eventually this might be a MELPA package.

But for now, you can do this.

(add-to-list 'load-path "~/.emacs.d/site-lisp/projectile-drupal")
(require 'projectile-drupal)

Usage

Hooking up with Projectile

To make it start alongside `projectile-mode`:

(add-hook 'projectile-mode-hook 'projectile-drupal-on)

That will start it only if the current project is a Drupal project.

Probably you should read Projectile’s README on setting up the completion system, caching and indexing files. Although the default settings are quite sensible and you should be ready to go without much tweaking.

Interactive commands

CommandKeybindingDescription
projectile-drupal-find-site-directory<kbd>C-c . d s</kbd>Go to Drupal Root
projectile-drupal-find-theme-directory<kbd>C-c . d T</kbd>Go to base theme directory
projectile-drupal-find-module-directory<kbd>C-c . d m</kbd>Go to base module directory
projectile-drupal-find-custom-directory<kbd>C-c . d c</kbd>Go to custom module directory
projectile-drupal-find-feature-directory<kbd>C-c . d f</kbd>Go to feature module directory
projectile-drupal-find-contrib-directory<kbd>C-c . d b</kbd>Go to contrib mdoule directory
projectile-drupal-find-profile-theme-directory<kbd>C-c . d t</kbd>Go to ‘default_theme’ directory
projectile-drupal-find-default-directory<kbd>C-c . d d</kbd>Go to sites/default directory
projectile-drupal-find-sites-all-directory<kbd>C-c . d a</kbd>Go to sites/all directory
projectile-drupal-find-settings-file-name<kbd>C-c . d S</kbd>Go to settings.php file
projectile-drupal-find-readme<kbd>C-c . d r</kbd>Go to Readme file in Drupal ROOT
projectile-drupal-find-settings-local-file-name<kbd>C-c . d l</kbd>Go to local.settings.php file
projectile-drupal-find-profile-directory<kbd>C-c . d p</kbd>Go to ‘profile’ directory
projectile-drupal-drush-cache-clear-all<kbd>C-c . c c</kbd>Clear cache
projectile-drupal-drush-uli-to-string<kbd>C-c . d e</kbd>Run drush –uli
projectile-drupal-drush-version<kbd>C-c . d v</kbd>Display drupal version
projectile-drupal-drush-watchdog-show<kbd>C-c . w s</kbd>drush watchdog-show*
projectile-drupal-drush-core-status<kbd>C-c . c s</kbd>drush core-status*
projectile-drupal-drush-core-status-debug<kbd>C-c . c d</kbd>drush core-status –debug*
projectile-drupal-drush-pm-info<kbd>C-c . p i</kbd>drush pm-info*
projectile-drupal-drush-modules-nocore<kbd>C-c . m n</kbd>drush pm-list –status=enabled –no-core –type=module
projectile-drupal-drush-features-list<kbd>C-c . f l</kbd>drush features-list
projectile-drupal-drush-features-enabled<kbd>C-c . f e</kbd>drush features-list –status=enabled
projectile-drupal-drush-up<kbd>C-c . u p</kbd>drush up -n –pipe
projectile-drupal-drush-get-variable<kbd>C-c . g v</kbd>Interactive display variable in status bar
projectile-drupal-drush-get-variables<kbd>C-c . g V</kbd>Displays all system table variables in buffer
projectile-drupal-drush-sql-sync-prod<kbd>C-c . s p</kbd>Drush sql-sync from prod to local
projectile-drupal-drush-sql-sync-stage<kbd>C-c . s s</kbd>Drush sql-sync from stage to local
projectile-drupal-drush-sql-sync-dev<kbd>C-c . s d</kbd>Drush sql-sync from dev to local
projectile-drupal-drush-rsync-prod<kbd>C-c . r p</kbd>Drush rsync from prod to local
projectile-drupal-drush-rsync-stage<kbd>C-c . r s</kbd>Drush rsync from stage to local
projectile-drupal-drush-rsync-dev<kbd>C-c . r d</kbd>Drush rsync from dev to local
projectile-drupal-choose-cu-site-prod<kbd>C-c . b p</kbd>Open prod site in browser
projectile-drupal-choose-cu-site-stage<kbd>C-c . b s</kbd>Open stage site in browser
projectile-drupal-choose-cu-site-dev<kbd>C-c . b d</kbd>Open dev site in browser
projectile-drupal-choose-cu-site-test<kbd>C-c . b t</kbd>Open test site in browser

You might want to create your own keybinding for your favorite commands. For example:

(define-key projectile-drupal-mode-map (kbd "s-c")   'projectile-drupal-find-custom-directory)
(define-key projectile-drupal-mode-map (kbd "s-S")   'projectile-drupal-find-settings-file-name)

Eshell

If you use eshell, you can tap into the power of projectile-drupal by putting the following aliaes in you eshell-alias-file.

alias 8dr vo $projectile-drupal-readme-file-name
alias 8dt cd $projectile-drupal-theme-directory
alias 8db cd $projectile-drupal-contrib-directory
alias 8df cd $projectile-drupal-feature-directory
alias 8dc cd $projectile-drupal-custom-directory
alias 8dm cd $projectile-drupal-module-directory
alias 8dp cd $projectile-drupal-profile-directory
alias 8ds cd (projectile-project-root)
alias 8dT cd $projectile-drupal-theme-directory
alias 8dt cd $projectile-drupal-default-theme-directory
alias 8dd cd $projectile-drupal-default-directory
alias 8da cd $projectile-drupal-sites-all-directory
alias 8dS vo $projectile-drupal-settings-file-name
alias 8dl vo $projectile-drupal-settings-local-file-name
alias si drush -y si $(curr-dir-project-string)
alias dl drush dl $1 --destination=$projectile-drupal-contrib-directory --select

Beyond

Consider installing other Emacs packages that can help you working specifically with Drupal projects such as drupal-mode for editing drupal files.

Templates

ExtensionAlternatives
tpl.phpweb-mode, mmm-mode
yamlyaml-mode

Running drush

Some of the Projectile Drupal functions run the drush executable.

OS X users might want to look at exec-path-from-shell.

Miscellaneous

Contribution

Pull requests and issues are welcome as I would like this project to grow to support Drupal 8 with emacs.

Inspiration

Inspired by subDrush and projectile-rails.