Tab width differences between modes

Asked by nurikabe

Is there a way to unify tab width in both modes? For example, when I am in PHP mode the tab width is four space, but in HTML mode it eight spaces. Some of my co-developers use actual tabs to align code, which then causes my buffer to jump rather wildly as I move between regions.

Or perhaps this is something I need to set externally to nXhtml?

Question information

Language:
English Edit question
Status:
Solved
For:
nXhtml Edit question
Assignee:
No assignee Edit question
Solved by:
nurikabe
Solved:
Last query:
Last reply:

This question was reopened

Revision history for this message
lborgman (lennart-borgman) said :
#1

Hi nurikabe,

I don't know exactly how tabs are handled by different major modes. Could you perhaps ask on the help-gnu-emacs mailing list for example?

Then we can see how it can be handled for multi major modes.

Revision history for this message
nurikabe (nurikabe) said :
#2

Actually, I realized that I have an php-mode-hook where I, not php-mode, have set tab-width to four. So I guess the tab jumping is to be expected.

Sorry for the confusion.

Revision history for this message
nurikabe (nurikabe) said :
#3

Coming back to this.. If I wanted to set the tab width in nxhtml, how would I do that? Setting tab-width via an 'nxhtml-mode-hook doesn't seem to work.

Revision history for this message
lborgman (lennart-borgman) said :
#4

Hi nurikabe,

I think there is some confusion and that my bad initial naming of things is to blame. The package is called "nXhtml", because originally there was only a major mode for editing XHTML. That major mode was (and is) called nxhtml-mode.

However then I turned to those things you use today, like php etc, which is kind of mix of different major modes in Emacs sense.

Then I added MuMaMo (mumamo.el, multiple major modes in a buffer). There is also hooks for MuMaMo. Take a look at

   mumamo-change-major-mode-hook
   mumamo-after-change-major-mode-hook

Those might be useful for you here.

Revision history for this message
nurikabe (nurikabe) said :
#5

Hook-wise, these will probably do the trick. I can't seem to figure out what mumamo uses to set indent level, however. It doesn't appear to be tab-width or sgml-basic-offset. Is there something like a mumamo-offset-width (or whatever) that I should be setting?

Revision history for this message
lborgman (lennart-borgman) said :
#6

It is supposed to work roughly like this:

- Inside a chunk the indentation functions for that major mode is used. (If it is possible, this is not yet structured very well in Emacs and those writing new modes does not always understand why it should be that.)

- At the borders some speical values are used. Please do "M-x customize-group RET mumamo RET" to set those variables.

- In some cases subchunks are part of a line and gives a new structure to the file. Then those subchunks are investigated and used for indentation. (This is done by extracting the inner contents from those subchunks and putting that in a separate buffer and then try indentation there. I think there is no good way to see where this is used yet.)

Revision history for this message
nurikabe (nurikabe) said :
#7

Found it! Setting nxml-child-indent adjusts the xhtml indentation levels. tab-width and sgml-basic-offset don't do it.

Thanks again for nXhtml. I've been bouncing around in the source. This is a massive amount of work!

Revision history for this message
lborgman (lennart-borgman) said :
#8

Thanks nurikabe.

So indentation level is another area where a bit more generic hierarchical structure is needed. I will try to remember to take this up on the Emacs developers mailing list.