New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
editorconfig-indentation-alist: php-mode #116
Comments
It is because php-mode is a child mode of c-mode!
Thanks for this helpful information! I did not know about that. My understanding: we should be aware of that, but luckily it does not cause any problems with current editorconfig empl, right? |
|
@10sr: Oh, that's a clever implementation. So that is why EditorConfig works with PHP files anyway. I was wondering how it achieved that. As for the Note that But the good news is, editorconfig runs as a hook when the major mode changes, so it still re-applies the correct offset every time that happens. Maybe you want to write down these 2 facts somewhere in the project (a brief code comment perhaps) for your own usage, since it could help with future bugtracking. Or just memorize the existence of this ticket, if php-mode ever comes back to bite. ;-) PS: Lots of modes that (also derive from c-mode?) and use c-basic-offset are listed independently. Why not add |
About `php-mode-coding-style'. They basically do this at mode startup: "if php-mode-coding-style is 'pear' (which it is by default), add a c-style called 'pear' and switch to it", and that style contains a c-basic-offset value. But since we're hooking later than that, we're welcome to override c-basic-offset without any risk. Also, php-mode suggests manually typing "nxml-mode" and "js2-mode" and "web-mode" and then "php-mode" etc, to switch editing styles if you have a document with multiple types of content (which is common in .php files), and every time you type php-mode, it runs that style injection again and resets c-basic-offset. However, editorconfig runs as a hook when the major mode changes, so it still re-applies the correct offset every time that happens. See #116 for more details.
|
Good point! Also I added a brief code comment, and wrote a bit more to the commit comment, which we can find via git-blame ;-) |
|
Shall we close this issue? |
Any reason why PHP isn't in the indentation mode list?
Here's what it should look like if you want to add it:
(php-mode c-basic-offset)As per: http://php-mode.sourceforge.net/html-manual/Indentation.html
You would normally also need to override
php-mode-coding-styleand set it to Default (instead of PEAR) whenever you want your own indentation to take effect: emacs-php/php-mode#226. But because you're injecting via a hook after the style has already been applied, you're free to overridec-basic-offsetwithout touching the php style parameter.The text was updated successfully, but these errors were encountered: