Index: src/buffer.h =================================================================== RCS file: /cvsroot/emacs/emacs/src/buffer.h,v retrieving revision 1.85 diff -u -d -r1.85 buffer.h --- src/buffer.h 10 Jan 2002 11:13:17 -0000 1.85 +++ src/buffer.h 15 Jun 2002 17:38:29 -0000 @@ -594,10 +594,11 @@ Lisp_Object category_table; /* Values of several buffer-local variables. */ - /* tab-width is buffer-local so that redisplay can find it - in buffers that are not current. */ + /* tab-width and display-tab-width are buffer-local so that + redisplay can find it in buffers that are not current. */ Lisp_Object case_fold_search; Lisp_Object tab_width; + Lisp_Object display_tab_width; Lisp_Object fill_column; Lisp_Object left_margin; /* Function to call when insert space past fill column. */ Index: src/buffer.c =================================================================== RCS file: /cvsroot/emacs/emacs/src/buffer.c,v retrieving revision 1.388 diff -u -d -r1.388 buffer.c --- src/buffer.c 8 Jun 2002 20:25:31 -0000 1.388 +++ src/buffer.c 15 Jun 2002 17:38:30 -0000 @@ -4859,6 +4859,7 @@ XSETFASTINT (buffer_defaults.overlay_center, BEG); XSETFASTINT (buffer_defaults.tab_width, 8); + buffer_defaults.display_tab_width = Qnil; buffer_defaults.truncate_lines = Qnil; buffer_defaults.ctl_arrow = Qt; buffer_defaults.direction_reversed = Qnil; @@ -4919,6 +4920,7 @@ XSETFASTINT (buffer_local_flags.selective_display_ellipses, idx); ++idx; #endif XSETFASTINT (buffer_local_flags.tab_width, idx); ++idx; + XSETFASTINT (buffer_local_flags.display_tab_width, idx); ++idx; XSETFASTINT (buffer_local_flags.truncate_lines, idx); ++idx; XSETFASTINT (buffer_local_flags.ctl_arrow, idx); ++idx; XSETFASTINT (buffer_local_flags.fill_column, idx); ++idx; @@ -5288,7 +5290,28 @@ DEFVAR_PER_BUFFER ("tab-width", ¤t_buffer->tab_width, make_number (Lisp_Int), - doc: /* *Distance between tab stops (for display of tab characters), in columns. */); + doc: /* *Distance between tab stops, in columns. +Historically, this variable was only meant to represent the number of +columns which compose a tab character for display purposes. However, +a number of packages began to use it for conversion between tab and +space characters (e.g. `tabify'), as well as calculating how many +tab/space characters to insert into a buffer (e.g. CC mode). + +Therefore, the variable `display-tab-width' (which see) was introduced +to allow you to control the display of a tab character, independently +of how many columns (space characters) you wish it to actually occupy +in the buffer. */); + + DEFVAR_PER_BUFFER ("display-tab-width", ¤t_buffer->display_tab_width, + make_number (Lisp_Int), + doc: /* *Distance between tab stops (for display of tab characters), in columns. +In addition to an integer, this variable can also be nil, in which +case the value of `tab-width' is used. + +This variable is only meant for controlling how literal tab characters +are displayed to the user; do not use it to convert between tab and +actual space characters or other purposes! Instead, use the variable +`tab-width' for that. */); DEFVAR_PER_BUFFER ("ctl-arrow", ¤t_buffer->ctl_arrow, Qnil, doc: /* *Non-nil means display control chars with uparrow.