The following is the solution from Jordon Biondo at "Writing PHP with SQL queries in emacs""Writing PHP with SQL queries in emacs" supplemented by alignment of the first spaces and equal signs.
You can further adapt the alignment rules in align
to your liking (see the description of the variable align-rules-list
).
The packages expand-region
and sql-indent
from MELPA are required. (That is already mentioned at the above linkthe above link.)
For aligning an sql-string put the point into the string and call sql-indent-string
. There is a nice video at the above linkthe above link that demonstrates the usage.
NOTE: Once more for clarification: The original codeoriginal code is from Jordon Biondo. I have just added the alignment stuff that was wanted here.