Wireshark-dev: [Wireshark-dev] tab-width considered less effective than some might think
The tab-width GNU Emacs mode appears to affect what a tab character in
a file does; to quote the GNU Emacs manual:
Some ASCII control characters are displayed in special ways. The
newline character (octal code 012) is displayed by starting a new
line. The tab character (octal code 011) is displayed by moving to
the next tab stop column (normally every 8 columns).
...
Normally, a tab character in the buffer is displayed as whitespace
which extends to the next display tab stop position, and display tab
stops come at intervals equal to eight spaces. The number of spaces
per tab is controlled by the variable tab-width, which is made local
by changing it. Note that how the tab character in the buffer is
displayed has nothing to do with the definition of <TAB> as a
command. The variable tab-width must have an integer value between 1
and 1000, inclusive. The variable default-tab-width controls the
default value of this variable for buffers where you have not set it
locally.
The XEmacs tutorial on indentation says:
It is possible to change the way a tab character is displayed. `vi'
users do this. For example, they can set the width of a tab
character to 4, and this enables them to hit TAB at the beginning of
a line to indent the body of a loop, say, by one indentation step
(of 4 characters). Normally, the width of tab is eight characters,
so a file created by a `vi' user with a tab width of 4 will look
different when viewed in a program which uses the default tab width
setting.
In order to correctly view files with non-standard tab width
settings, it is possible to set the variable tab-width, like this:
(setq-default tab-width 4)
However, not all text editors are GNU Emacs or vi...
...and not all text processing tools are text editors. "cat", for
example, doesn't know about Emacs mode lines, and I don't think "more"
or "less" do, either.
At least on UN*X, it's probably best to assume that a tab character in
a file advances to the next tab stop, with tab stops set every 8
characters. Yes, this means that if you want 4-space indents, you
can't use tab characters, although it might be possible to configure
your editor so that typing the tab key indents every 2, or 4, or...
spaces, e.g. by setting c-basic-offset to 4 in GNU Emacs.