2008-01-08

Finally the annoying "elseif" indentation bug is solve in php-mode

I browsed emacswiki this morning and found that there is another new version of php-mode. With the hope that this version will solve the annoying and ugly "elseif" indentation bug in my emacs, which is like("_" stands for One SPACE here)


if($true)
__{
__}
elseif($false)
{
}
else
___{
___}


I immediately downloaded that new mode file and installed it, later added several tunings:


(add-hook 'php-mode-hook
'(lambda () (define-abbrev php-mode-abbrev-table "ex" "extends")))


Now, time to try it!! Very lucky, that bug has now disappeared! See this screnshot:




// also, I add "print_r"to the constant php-keywords in php-mode.el to make it appears just the same as "echo":


(defconst php-keywords
(eval-when-compile
(regexp-opt
;; "class", "new" and "extends" get special treatment
;; "case" and "default" get special treatment elsewhere
'("and" "as" "break" "continue" "declare" "do" "echo" "else" "elseif"
"endfor" "endforeach" "endif" "endswitch" "endwhile" "exit"
"extends" "for" "foreach" "global" "if" "include" "include_once"
"next" "or" "print_r" "require" "require_once" "return" "static" "switch"
"then" "var" "while" "xor" "private" "throw" "catch" "try"
"instanceof" "catch all" "finally")))
"PHP keywords.")

没有评论: