Description
I apologize if php-mode was only intended to use the four styles mentioned in the readme, but I know for certain I indent my code in Whitesmith style, so that's what I've been using because there isn't clear documentation on the php-mode styles. If there is a Whitesmith-like I should be using, feel free to point me toward it.
I've noticed two issues that are more of an annoyance to me, for each of which I have a workaround and are not present in K&R. First is close braces are indented one indent deeper than their matching open braces. I was not able to replicate this behavior in other major modes, although I'm new to Emacs, so I may not have controlled the offset variables well enough in my tests. I'm able to circumvent this behavior by manually setting the close offsets to 0 after loading php-mode and switching to the Whitesmith style.
Second, I noticed while using electric-pair that functions, if's / and elseif's, and any line requiring parentheses will indent to two different places depending on if the cursor is within the parentheses. If the cursor is between the parentheses where the argument variables go, functions, if's, and else's will indent one deeper than the braces, putting them two deeper than the class and function level code beneath them. If the cursor is at the end of the line during the indent, these lines are appropriately indented to be in line with the braces and one deeper than the class and function level code beneath them. This behavior can be replicated after a line has its argument list closed by going to the end of the line, indenting, moving the cursor into the parentheses, and indenting again.
Here is an example of what I can indent my code to look like if I indent while in the parentheses of each line:
class namespace ()
{
function foo ()
{
if ($x)
{
echo $bar;
}
}
}
If I put parentheses around $bar
, I can give echo $bar
an additional indent by indenting with my cursor in the parentheses. With electric-pair off, the line indents too far when opening parentheses, and indents it back to proper depth when closing parentheses. Using electric-pair, because open and close are done in that order in one function, indents the line too far, and must be indented back by moving to the end of the line and issuing the indent command.
Where if I indent at the end of the lines, I get (and should only get) this:
class namespace ()
{
function foo ()
{
if ($x);
{
echo $bar;
}
}
}
My php-mode-modified
variable is 2013-09-20
, and my php-mode-version
variable is 1.12
.