Ticket #3068: mcedit-vim-modeline-4.patch

File mcedit-vim-modeline-4.patch, 19.4 KB (added by twasilczyk, 11 years ago)

Various comment types supported

  • .gitignore

    diff --git a/.gitignore b/.gitignore
    index 310c62f..9e8b9e7 100644
    a b make.log 
    4646make.clang 
    4747make.gcc 
    4848make.tcc 
     49misc/ext.d/doc.sh 
     50misc/ext.d/misc.sh 
     51misc/ext.d/text.sh 
     52misc/ext.d/web.sh 
     53misc/syntax/Syntax 
     54src/man2hlp/man2hlp 
     55src/vfs/extfs/helpers/uc1541 
     56src/vfs/extfs/helpers/ulib 
     57tests/src/editor/test-data.txt 
  • src/editor/edit-impl.h

    diff --git a/src/editor/edit-impl.h b/src/editor/edit-impl.h
    index e840d30..5eb417e 100644
    a b  
    5959#define MARK_CURS       1000000000 
    6060#define KEY_PRESS       1500000000 
    6161 
    62 /* Tabs spaces: (sofar only HALF_TAB_SIZE is used: */ 
    63 #define TAB_SIZE      option_tab_spacing 
    64 #define HALF_TAB_SIZE ((int) option_tab_spacing / 2) 
    65  
    6662/* max count stack files */ 
    6763#define MAX_HISTORY_MOVETO     50 
    6864#define LINE_STATE_WIDTH 8 
    void format_paragraph (WEdit * edit, gboolean force); 
    286282/* either command or char_for_insertion must be passed as -1 */ 
    287283void edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion); 
    288284 
     285int edit_tab_spacing(const WEdit *edit, gboolean half); 
     286 
    289287/*** inline functions ****************************************************************************/ 
    290288 
    291289/** 
  • src/editor/edit.c

    diff --git a/src/editor/edit.c b/src/editor/edit.c
    index 1c80466..f48bac1 100644
    a b static const off_t option_filesize_default_threshold = 64 * 1024 * 1024; 
    142142/* --------------------------------------------------------------------------------------------- */ 
    143143/*** file scope functions ************************************************************************/ 
    144144/* --------------------------------------------------------------------------------------------- */ 
     145 
     146static gboolean 
     147edit_fake_half_tabs(WEdit *edit) 
     148{ 
     149    if (edit->force_halftabs == -1) 
     150        return option_fake_half_tabs; 
     151    return edit->force_halftabs; 
     152} 
     153 
     154static gboolean 
     155edit_fill_tabs_with_spaces(WEdit *edit) 
     156{ 
     157    if (edit->force_fill_tabs_with_spaces == -1) 
     158        return option_fill_tabs_with_spaces; 
     159    return edit->force_fill_tabs_with_spaces; 
     160} 
     161 
     162int 
     163edit_tab_spacing(const WEdit *edit, gboolean half) 
     164{ 
     165    int spacing = option_tab_spacing; 
     166    if (edit->force_tab_spacing > 0) 
     167        spacing = edit->force_tab_spacing; 
     168    if (half) 
     169        spacing /= 2; 
     170    return spacing; 
     171} 
     172 
    145173/** 
    146174 * Load file OR text into buffers.  Set cursor to the beginning of file. 
    147175 * 
    is_aligned_on_a_tab (WEdit * edit) 
    13021330    long curs_col; 
    13031331 
    13041332    edit_update_curs_col (edit); 
    1305     curs_col = edit->curs_col % (TAB_SIZE * space_width); 
    1306     return (curs_col == 0 || curs_col == (HALF_TAB_SIZE * space_width)); 
     1333    curs_col = edit->curs_col % (edit_tab_spacing(edit, FALSE) * space_width); 
     1334    return (curs_col == 0 || curs_col == (edit_tab_spacing(edit, TRUE) * space_width)); 
    13071335} 
    13081336 
    13091337/* --------------------------------------------------------------------------------------------- */ 
    right_of_four_spaces (WEdit * edit) 
    13131341{ 
    13141342    int i, ch = 0; 
    13151343 
    1316     for (i = 1; i <= HALF_TAB_SIZE; i++) 
     1344    for (i = 1; i <= edit_tab_spacing(edit, TRUE); i++) 
    13171345        ch |= edit_buffer_get_byte (&edit->buffer, edit->buffer.curs1 - i); 
    13181346 
    13191347    return (ch == ' ' && is_aligned_on_a_tab (edit)); 
    left_of_four_spaces (WEdit * edit) 
    13261354{ 
    13271355    int i, ch = 0; 
    13281356 
    1329     for (i = 0; i < HALF_TAB_SIZE; i++) 
     1357    for (i = 0; i < edit_tab_spacing(edit, TRUE); i++) 
    13301358        ch |= edit_buffer_get_byte (&edit->buffer, edit->buffer.curs1 + i); 
    13311359 
    13321360    return (ch == ' ' && is_aligned_on_a_tab (edit)); 
    insert_spaces_tab (WEdit * edit, gboolean half) 
    13741402    long i; 
    13751403 
    13761404    edit_update_curs_col (edit); 
    1377     i = option_tab_spacing * space_width; 
    1378     if (half) 
    1379         i /= 2; 
     1405    i = edit_tab_spacing(edit, half) * space_width; 
    13801406    if (i != 0) 
    13811407    { 
    13821408        i = ((edit->curs_col / i) + 1) * i - edit->curs_col; 
    insert_spaces_tab (WEdit * edit, gboolean half) 
    13931419static inline void 
    13941420edit_tab_cmd (WEdit * edit) 
    13951421{ 
    1396     if (option_fake_half_tabs && is_in_indent (&edit->buffer)) 
     1422    if (edit_fake_half_tabs(edit) && is_in_indent (&edit->buffer)) 
    13971423    { 
    13981424        /* insert a half tab (usually four spaces) unless there is a 
    13991425           half tab already behind, then delete it and insert a 
    14001426           full tab. */ 
    1401         if (option_fill_tabs_with_spaces || !right_of_four_spaces (edit)) 
     1427        if (edit_fill_tabs_with_spaces(edit) || !right_of_four_spaces (edit)) 
    14021428            insert_spaces_tab (edit, TRUE); 
    14031429        else 
    14041430        { 
    14051431            int i; 
    14061432 
    1407             for (i = 1; i <= HALF_TAB_SIZE; i++) 
     1433            for (i = 1; i <= edit_tab_spacing(edit, TRUE); i++) 
    14081434                edit_backspace (edit, TRUE); 
    14091435            edit_insert (edit, '\t'); 
    14101436        } 
    14111437    } 
    1412     else if (option_fill_tabs_with_spaces) 
     1438    else if (edit_fill_tabs_with_spaces(edit)) 
    14131439        insert_spaces_tab (edit, FALSE); 
    14141440    else 
    14151441        edit_insert (edit, '\t'); 
    edit_move_block_to_right (WEdit * edit) 
    15451571        edit_cursor_move (edit, cur_bol - edit->buffer.curs1); 
    15461572        if (!edit_line_is_blank (edit, edit->buffer.curs_line)) 
    15471573        { 
    1548             if (option_fill_tabs_with_spaces) 
    1549                 insert_spaces_tab (edit, option_fake_half_tabs); 
     1574            if (edit_fill_tabs_with_spaces(edit)) 
     1575                insert_spaces_tab (edit, edit_fake_half_tabs(edit)); 
    15501576            else 
    15511577                edit_insert (edit, '\t'); 
    15521578            edit_cursor_move (edit, 
    edit_move_block_to_left (WEdit * edit) 
    15851611 
    15861612        edit_cursor_move (edit, cur_bol - edit->buffer.curs1); 
    15871613 
    1588         if (option_fake_half_tabs) 
    1589             del_tab_width = HALF_TAB_SIZE; 
    1590         else 
    1591             del_tab_width = option_tab_spacing; 
     1614        del_tab_width = edit_tab_spacing(edit, edit_fake_half_tabs(edit)); 
    15921615 
    15931616        next_char = edit_buffer_get_current_byte (&edit->buffer); 
    15941617        if (next_char == '\t') 
    edit_insert_file (WEdit * edit, const vfs_path_t * filename_vpath) 
    20172040 * cursor on that line and show it in the middle of the screen. 
    20182041 */ 
    20192042 
     2043static off_t 
     2044mc_findinfile(int handle, const gchar **searchstrs) 
     2045{ 
     2046    off_t offset_bak, offset_cur, filesize; 
     2047    char buff[10240]; 
     2048    ssize_t got; 
     2049    const char *found; 
     2050    size_t i, smallest_searchstr_len, searchstrs_count; 
     2051 
     2052    searchstrs_count = 0; 
     2053    smallest_searchstr_len = strlen(searchstrs[0]); 
     2054    while (searchstrs[searchstrs_count] != NULL) { 
     2055        size_t len = strlen(searchstrs[searchstrs_count]); 
     2056        if (smallest_searchstr_len > len) 
     2057            smallest_searchstr_len = len; 
     2058        searchstrs_count++; 
     2059    } 
     2060 
     2061    offset_bak = mc_lseek(handle, 0, SEEK_CUR); 
     2062    if (offset_bak < 0) 
     2063        return -1; 
     2064 
     2065    filesize = mc_lseek(handle, 0, SEEK_END); 
     2066    offset_cur = mc_lseek(handle, offset_bak, SEEK_SET); 
     2067 
     2068    do { 
     2069        got = mc_read(handle, buff, sizeof(buff) - 1); 
     2070        if (got <= 0) 
     2071            return -1; 
     2072        buff[got] = '\0'; 
     2073 
     2074        for (i = 0; i < searchstrs_count; i++) { 
     2075            /* this could be done in O(n), not O(n*m) */ 
     2076            found = strstr(buff, searchstrs[i]); 
     2077            if (found) { 
     2078                return mc_lseek(handle, offset_cur + (found - buff), SEEK_SET) + 
     2079                    strlen(searchstrs[i]); 
     2080            } 
     2081        } 
     2082 
     2083        offset_cur = mc_lseek(handle, 
     2084            offset_cur + (sizeof(buff) - 1) - smallest_searchstr_len, SEEK_SET); 
     2085    } while (offset_cur + smallest_searchstr_len < filesize); 
     2086 
     2087    return -1; 
     2088} 
     2089 
     2090static void 
     2091scan_modeline(WEdit *edit, const vfs_path_t *filename) 
     2092{ 
     2093    int fd; 
     2094    int conf_tabstop = -1; 
     2095    int conf_softtabstop = -1; 
     2096    int conf_expandtab = -1; 
     2097    int dst_halftabs = -1; 
     2098    int dst_fill_tabs_with_spaces = -1; 
     2099    int dst_force_tab_spacing = -1; 
     2100    const gchar *searchstrs[] = { 
     2101        "\n/*", "\n//", "\n#", "\ndnl", NULL 
     2102    }; 
     2103 
     2104    fd = mc_open(filename, O_RDONLY | O_BINARY); 
     2105    while (1) { 
     2106        off_t foundat; 
     2107        char buff[200]; 
     2108        const char *s; 
     2109        ssize_t got; 
     2110        const char *foundstr; 
     2111 
     2112        foundat = mc_findinfile(fd, searchstrs); 
     2113        if (foundat < 0) 
     2114            return; 
     2115 
     2116        mc_lseek(fd, foundat, SEEK_SET); 
     2117 
     2118        got = mc_read(fd, buff, sizeof(buff) - 1); 
     2119        if (got <= 0) 
     2120            return; 
     2121        buff[got] = '\0'; 
     2122 
     2123        s = buff; 
     2124        while (*s == ' ' || *s == '\t' || *s == '\n' || *s == '\r') 
     2125            s++; 
     2126        if (strncmp(s, "vim:", 4) != 0) 
     2127            continue; 
     2128        s += 4; 
     2129 
     2130        foundstr = strstr(s, "tabstop="); 
     2131        if (foundstr) 
     2132            conf_tabstop=atoi(foundstr + 8); 
     2133        foundstr = strstr(s, "softtabstop="); 
     2134        if (foundstr) 
     2135            conf_softtabstop=atoi(foundstr + 12); 
     2136        foundstr = strstr(s, "expandtab"); 
     2137        if (foundstr) 
     2138            conf_expandtab = 1; 
     2139        foundstr = strstr(s, "noexpandtab"); 
     2140        if (foundstr) 
     2141            conf_expandtab = 0; 
     2142 
     2143        break; 
     2144    } 
     2145 
     2146    if (conf_softtabstop > 0 && conf_tabstop > 0 && 
     2147        conf_softtabstop * 2 == conf_tabstop) 
     2148    { 
     2149        dst_halftabs = 1; 
     2150    } 
     2151 
     2152    dst_fill_tabs_with_spaces = conf_expandtab; 
     2153 
     2154    dst_force_tab_spacing = conf_tabstop; 
     2155 
     2156    edit->force_halftabs = dst_halftabs; 
     2157    edit->force_fill_tabs_with_spaces = dst_fill_tabs_with_spaces; 
     2158    edit->force_tab_spacing = dst_force_tab_spacing; 
     2159 
     2160    mc_close(fd); 
     2161} 
     2162 
    20202163WEdit * 
    20212164edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * filename_vpath, 
    20222165           long line) 
    edit_init (WEdit * edit, int y, int x, int lines, int cols, const vfs_path_t * f 
    20542197        edit_save_size (edit); 
    20552198    } 
    20562199 
     2200    edit->force_halftabs = -1; 
     2201    edit->force_fill_tabs_with_spaces = -1; 
     2202    edit->force_tab_spacing = -1; 
     2203 
     2204    scan_modeline(edit, filename_vpath); 
     2205 
    20572206    edit->drag_state = MCEDIT_DRAG_NORMAL; 
    20582207 
    20592208    edit->stat1.st_mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH; 
    edit_move_forward3 (const WEdit * edit, off_t current, long cols, off_t upto) 
    27552904 
    27562905        if (c == '\n') 
    27572906            return (upto != 0 ? (off_t) col : p); 
    2758         if (c == '\t') 
    2759             col += TAB_SIZE - col % TAB_SIZE; 
     2907        if (c == '\t') { 
     2908            int tab_size = edit_tab_spacing(edit, FALSE); 
     2909            col += tab_size - col % tab_size; 
     2910        } 
    27602911        else if ((c < 32 || c == 127) && (orig_c == c 
    27612912#ifdef HAVE_CHARSET 
    27622913                                          || (!mc_global.utf8_display && !edit->utf8) 
    edit_move_to_prev_col (WEdit * edit, off_t p) 
    29093060    else 
    29103061    { 
    29113062        edit->over_col = 0; 
    2912         if (option_fake_half_tabs && is_in_indent (&edit->buffer)) 
     3063        if (edit_fake_half_tabs(edit) && is_in_indent (&edit->buffer)) 
    29133064        { 
    29143065            long fake_half_tabs; 
    29153066 
    29163067            edit_update_curs_col (edit); 
    29173068 
    2918             fake_half_tabs = HALF_TAB_SIZE * space_width; 
     3069            fake_half_tabs = edit_tab_spacing(edit, TRUE) * space_width; 
    29193070            if (fake_half_tabs != 0 && edit->curs_col % fake_half_tabs != 0) 
    29203071            { 
    29213072                int q; 
    edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion) 
    34023553            while (edit_buffer_get_previous_byte (&edit->buffer) != '\n' && edit->buffer.curs1 > 0) 
    34033554                edit_backspace (edit, TRUE); 
    34043555        } 
    3405         else if (option_fake_half_tabs && is_in_indent (&edit->buffer) 
     3556        else if (edit_fake_half_tabs(edit) && is_in_indent (&edit->buffer) 
    34063557                 && right_of_four_spaces (edit)) 
    34073558        { 
    34083559            int i; 
    34093560 
    3410             for (i = 0; i < HALF_TAB_SIZE; i++) 
     3561            for (i = 0; i < edit_tab_spacing(edit, TRUE); i++) 
    34113562                edit_backspace (edit, TRUE); 
    34123563        } 
     3564        else if (edit_fake_half_tabs(edit) && is_in_indent (&edit->buffer) 
     3565                 && edit_buffer_get_byte(&edit->buffer, edit->buffer.curs1 - 1) == '\t') { 
     3566            int i; 
     3567 
     3568            edit_backspace (edit, TRUE); 
     3569            for (i = 0; i < edit_tab_spacing(edit, TRUE); i++) 
     3570                edit_insert (edit, ' '); 
     3571            /* TODO: if (right_of_four_spaces(edit) && left_of_four_spaces(edit) 
     3572             * - replace spaces with a tab */ 
     3573        } 
    34133574        else 
    34143575            edit_backspace (edit, FALSE); 
    34153576        break; 
    edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion) 
    34223583            if (option_cursor_beyond_eol && edit->over_col > 0) 
    34233584                edit_insert_over (edit); 
    34243585 
    3425             if (option_fake_half_tabs && is_in_indent (&edit->buffer) && left_of_four_spaces (edit)) 
     3586            if (edit_fake_half_tabs(edit) && is_in_indent (&edit->buffer) && left_of_four_spaces (edit)) 
    34263587            { 
    34273588                int i; 
    34283589 
    3429                 for (i = 1; i <= HALF_TAB_SIZE; i++) 
     3590                for (i = 1; i <= edit_tab_spacing(edit, TRUE); i++) 
    34303591                    edit_delete (edit, TRUE); 
    34313592            } 
    34323593            else 
    edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion) 
    34883649        edit->column_highlight = 1; 
    34893650    case CK_Left: 
    34903651    case CK_MarkLeft: 
    3491         if (option_fake_half_tabs && is_in_indent (&edit->buffer) && right_of_four_spaces (edit)) 
     3652        if (edit_fake_half_tabs(edit) && is_in_indent (&edit->buffer) && right_of_four_spaces (edit)) 
    34923653        { 
    34933654            if (option_cursor_beyond_eol && edit->over_col > 0) 
    34943655                edit->over_col--; 
    34953656            else 
    3496                 edit_cursor_move (edit, -HALF_TAB_SIZE); 
     3657                edit_cursor_move (edit, -edit_tab_spacing(edit, TRUE)); 
    34973658            edit->force &= (0xFFF - REDRAW_CHAR_ONLY); 
    34983659        } 
    34993660        else 
    edit_execute_cmd (WEdit * edit, unsigned long command, int char_for_insertion) 
    35033664        edit->column_highlight = 1; 
    35043665    case CK_Right: 
    35053666    case CK_MarkRight: 
    3506         if (option_fake_half_tabs && is_in_indent (&edit->buffer) && left_of_four_spaces (edit)) 
     3667        if (edit_fake_half_tabs(edit) && is_in_indent (&edit->buffer) && left_of_four_spaces (edit)) 
    35073668        { 
    3508             edit_cursor_move (edit, HALF_TAB_SIZE); 
     3669            edit_cursor_move (edit, edit_tab_spacing(edit, TRUE)); 
    35093670            edit->force &= (0xFFF - REDRAW_CHAR_ONLY); 
    35103671        } 
    35113672        else 
    edit_move_down (WEdit * edit, long i, gboolean do_scroll) 
    39644125} 
    39654126 
    39664127/* --------------------------------------------------------------------------------------------- */ 
     4128 
     4129/* vim: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */ 
  • src/editor/editcmd.c

    diff --git a/src/editor/editcmd.c b/src/editor/editcmd.c
    index 4347fd7..a51839c 100644
    a b  
    6767#endif 
    6868 
    6969#include "src/history.h" 
    70 #include "src/setup.h"          /* option_tab_spacing */ 
     70#include "src/setup.h" 
    7171#ifdef HAVE_CHARSET 
    7272#include "src/selcodepage.h" 
    7373#endif 
  • src/editor/editdraw.c

    diff --git a/src/editor/editdraw.c b/src/editor/editdraw.c
    index cd084de..c66b675 100644
    a b edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c 
    584584                int tab_over = 0; 
    585585                gboolean wide_width_char = FALSE; 
    586586                gboolean control_char = FALSE; 
     587                int tab_size = edit_tab_spacing(edit, FALSE); 
    587588 
    588589                p->ch = 0; 
    589590                p->style = 0; 
    edit_draw_this_line (WEdit * edit, off_t b, long row, long start_col, long end_c 
    632633                    col = end_col - edit->start_col + 1;        /* quit */ 
    633634                    break; 
    634635                case '\t': 
    635                     i = TAB_SIZE - ((int) col % TAB_SIZE); 
     636                    i = tab_size - ((int) col % tab_size); 
    636637                    tab_over = (end_col - edit->start_col) - (col + i - 1); 
    637638                    if (tab_over < 0) 
    638639                        i += tab_over; 
  • src/editor/editwidget.h

    diff --git a/src/editor/editwidget.h b/src/editor/editwidget.h
    index 90c73f6..d58e197 100644
    a b struct WEdit 
    163163    /* line break */ 
    164164    LineBreaks lb; 
    165165    gboolean extmod; 
     166 
     167    int force_halftabs; 
     168    int force_fill_tabs_with_spaces; 
     169    int force_tab_spacing; 
    166170}; 
    167171 
    168172/*** global variables defined in .c file *********************************************************/ 
    struct WEdit 
    171175 
    172176/*** inline functions ****************************************************************************/ 
    173177#endif /* MC__EDIT_WIDGET_H */ 
     178 
     179/* vim: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */ 
  • src/editor/wordproc.c

    diff --git a/src/editor/wordproc.c b/src/editor/wordproc.c
    index 8c42ce9..5358dab 100644
    a b  
    5050 
    5151#include "lib/global.h" 
    5252 
    53 #include "src/setup.h"          /* option_tab_spacing */ 
    54  
    5553#include "edit-impl.h" 
    5654#include "editwidget.h" 
    5755 
     
    5957 
    6058/*** file scope macro definitions ****************************************************************/ 
    6159 
    62 #define tab_width option_tab_spacing 
    63  
    6460#define NO_FORMAT_CHARS_START "-+*\\,.;:&>" 
    6561#define FONT_MEAN_WIDTH 1 
    6662 
    strip_newlines (unsigned char *t, off_t size) 
    205201 */ 
    206202 
    207203static inline off_t 
    208 next_tab_pos (off_t x) 
     204next_tab_pos (off_t x, int tab_width) 
    209205{ 
    210206    x += tab_width - x % tab_width; 
    211207    return x; 
    next_tab_pos (off_t x) 
    214210/* --------------------------------------------------------------------------------------------- */ 
    215211 
    216212static inline off_t 
    217 line_pixel_length (unsigned char *t, off_t b, off_t l, gboolean utf8) 
     213line_pixel_length (unsigned char *t, off_t b, off_t l, int tab_width, gboolean utf8) 
    218214{ 
    219215    off_t xn, x;                /* position conters */ 
    220216    off_t cw;                   /* character width in bytes */ 
    line_pixel_length (unsigned char *t, off_t b, off_t l, gboolean utf8) 
    235231        case '\n': 
    236232            return b; 
    237233        case '\t': 
    238             xn = next_tab_pos (x); 
     234            xn = next_tab_pos (x, tab_width); 
    239235            break; 
    240236        default: 
    241237#ifdef HAVE_CHARSET 
    word_start (unsigned char *t, off_t q, off_t size) 
    324320/** replaces ' ' with '\n' to properly format a paragraph */ 
    325321 
    326322static inline void 
    327 format_this (unsigned char *t, off_t size, long indent, gboolean utf8) 
     323format_this (unsigned char *t, off_t size, long indent, int tab_width, gboolean utf8) 
    328324{ 
    329325    off_t q = 0, ww; 
    330326 
    format_this (unsigned char *t, off_t size, long indent, gboolean utf8) 
    337333    { 
    338334        off_t p; 
    339335 
    340         q = line_pixel_length (t, q, ww, utf8); 
     336        q = line_pixel_length (t, q, ww, tab_width, utf8); 
    341337        if (q > size) 
    342338            break; 
    343339        if (t[q] == '\n') 
    edit_indent_width (const WEdit * edit, off_t p) 
    386382static void 
    387383edit_insert_indent (WEdit * edit, long indent) 
    388384{ 
     385    int tab_size = edit_tab_spacing(edit, FALSE); 
    389386    if (!option_fill_tabs_with_spaces) 
    390         while (indent >= TAB_SIZE) 
     387        while (indent >= tab_size) 
    391388        { 
    392389            edit_insert (edit, '\t'); 
    393             indent -= TAB_SIZE; 
     390            indent -= tab_size; 
    394391        } 
    395392 
    396393    while (indent-- > 0) 
    format_paragraph (WEdit * edit, gboolean force) 
    513510#ifdef HAVE_CHARSET 
    514511    utf8 = edit->utf8; 
    515512#endif 
    516     format_this (t2, q - p, indent, utf8); 
     513    format_this (t2, q - p, indent, edit_tab_spacing(edit, FALSE), utf8); 
    517514    put_paragraph (edit, t2, p, indent, size); 
    518515    g_free ((char *) t2); 
    519516 
    format_paragraph (WEdit * edit, gboolean force) 
    522519} 
    523520 
    524521/* --------------------------------------------------------------------------------------------- */ 
     522 
     523/* vim: set tabstop=8 softtabstop=4 shiftwidth=4 expandtab: */