From: Jeff D. <da...@da...> - 2001-09-08 21:24:16
|
Just to clarify, the php-mode tab-width setting does not affect how far blocks of code are indented (c-basic-offset controls that, and I'm not suggesting changing that). The tab-width setting (in combination with indent-tabs-mode (see below)) just controls how emacs achieves that indentation. If tab-width is set to 4 (as PEAR dictates), then emacs assumes that a tab character in the text moves to the next multiple of 4 columns. The problem with this, is that most text file viewers assume that a tab moves to the next multiple of 8 columns, so code which looks fine when viewed with a tab-width setting of 4 can look severely mangled when viewed with other programs. > I actually rangled over this for some time with some programmer friends. I > think I posted a link to this list that was something written by jwz about > why you should not use tabs at all. It was pretty sound. Yes, I agree. Setting indent-tabs-mode to 'nil forces php-mode not to use tabs at all, and just indent with spaces. This is good. The problem is that unless great care is taken to eliminate all tabs in the source code, some tabs will remain. When indentation is achieved with a mixture of spaces and tabs, then things get particularly badly munged when viewed by a viewer with a different idea of what the tab-width is. I think the intention of the PEAR standards is that indentation be achieved using only tabs. This allows individuals to adjust the displayed indentation just by changing the tab-width. The problem is that even when tab-width == c-basic-offset, emacs does not really guarantee that all indentation is achieved using tabs rather than spaces. If you use, e.g. 'less' to view the PEAR source code (at least the version I've got) the problem will be immediately obvious. In general, most blocks are indented 8 columns (since tabs were used) --- that's ugly and hard to read as you point out, but at least the indentation still properly shows the block structure. However some lines in the PEAR code are indented with spaces. Those lines only shift blocks over four columns. The result is that nothing lines up with anything. |