# sample script
# removes tabs from the selected text with proper tabstop sizing
# if no text is selected, is converts the hole buffer
# (C) 2000 Chicane (under GPL)

import glimmer
import string

if glimmer.has_selection():
    start = glimmer.selection_start()
    end = glimmer.selection_end()
    selection = 1
else:
    start = 0
    end = glimmer.buffer_size()
    selection = 0
file = glimmer.get_file_number()
l = glimmer.get_file_tab_width(file)
str = ""
glimmer.freeze()
str = glimmer.get_text(start, end)
str = string.expandtabs(str, l)
glimmer.delete_text(start, end)
glimmer.move_to(start)
glimmer.insert(str)
glimmer.thaw()
