Using Nano with Drupal
grayside — Thu, 11/12/2009 - 11:12
Janak Singh had a great introduction to tailoring Nano for use with Drupal. Here are the details of how I use Nano.
Because Drupal is not my entire PHP universe, I have created a separate syntax file specific to the sorts of files I typically use with Drupal. My drupal.nanorc is almost identical to my php.nanorc, but it highlights hook statements in comments and adds some extra coloring to drupal core API functions.
I identify Drupal API functions by two alternate criteria:
- The function starts with drupal_
- I’ve noticed myself using the function and remembered to add it.
It would be really helpful if a master API existed that excluded all the internal functions I will only ever need as background reference material. (It’s necessary to limit the functions in this way to avoid annoying 10 second .nanorc parsing times.)
drupal.nanorc
Here are some highlights from the attached file.
# Drupal syntax highlighting
syntax "drupal" "\.module$" "\.install$" "\.inc$" "\.view$" "\.tpl.php$"
# Drupal API functions
color blue "(arg|base_path|cache_get|cache_set|check_file|check_markup|check_plain)\W"
color blue start="drupal_" end="\W"
# Emphasize hooks in comments
color brightgreen start="hook_" end=")"Invoking Nano
For Drupal development, a simple alias to Nano in my .bashrc file switches it from general purpose to Drupal Coding.
alias nani='nano -i -E -T 2'
This enforces auto-indent, converts tabs to spaces, and resizes tab width to two spaces. This saves me a lot of time counting spaces for coding standards.