I am using Emacs with php-mode.el: http://php-mode.sourceforge.net/php-mode.el.html
I have the following lines in my .emacs file:
(load-file "~/.emacs.d/php-mode.el")
(require 'php-mode)
(setq c-default-style "linux" c-basic-offset 4)
It is working really nicely for the most part. The issue is that for certain bits of code Emacs displays the code differently to other editors. For example, I have the following code in Emacs:
public function showStuff($items, $Stuff) {
$restrict = true;
$stuff = false;
$moreStuff = true;
if (($restrict && $stuff >= $moreStuff)
|| ( $moreStuff > 10)) {
return true;
}
return false;
}
But viewing the same file in Eclipse/Sublime Text/Text Wrangler looks like:
public function showStuff($items, $Stuff) {
$restrict = true;
$stuff = false;
$moreStuff = true;
if (($restrict && $stuff >= $moreStuff)
|| ( $moreStuff > 10)) {
return true;
}
return false;
}
Can anyone comment on why I am seeing these results and a possible solution?
Thanks.
As it seems you want to use spaces rather than tabs, I think this is basically a duplicate of:
I can't find this: How do I use 4 SPACES instead of a TAB in EMACS?
Or if you wanted this only for PHP files, then you would use:
(add-hook 'php-mode-hook 'my-php-mode-hook)
(defun my-php-mode-hook ()
"My PHP mode configuration."
(setq indent-tabs-mode nil
tab-width 4
c-basic-offset 4))
Before that, with the code looking correct in Emacs, convert the tabs to spaces with:
untabify
RETI would also take a look at:
http://www.emacswiki.org/emacs/CategoryIndentation
(or take note of it, at least -- indentation can be trickier than expected in Emacs, and there's lots of good information there.)
I think the issue is simply that your Eclipse/Foo/Bar editors do not display the TABs in your files in the standard way (TABs have generally been defined as spanning 8 columns). Using a mix of spaces and TABs is not a problem (similar prolems would show up if you only used TABs for indentation), there does not seem to be anything that really needs fixing in your file. The best way to solve this is probably: