Re: [gedit-list] Plugin for automatically stripping trailing space

Hi Osmo,

> I wrote a simple Gedit plugin to automatically strip all trailing
> whitespace everytime when saving a document. The plugin will strip extra
> space and tab characters at the ends of lines as well as excess blank
> lines at the end of the document. A final newline will be preserved if
> it exists. The plugin is available at
> This is the first Gedit plugin I have written so there may be some rough
> edges, but it seems to work OK.

I have read the code of you plugin. I think it could be a good candidate
for inclusion in gedit-plugins (but I'm not maintaining it so nud and
jesse will decide).
BTW I think there are some issues we need to solve before including it:

1. the "saving" message can be emitted more then once when saving remote

2. I'm not sure modifying the buffer on "saving" will have any effect on
the saved document (have you verified the saved document you have on
disk really have not trailing spaces?)

3. I don't like very much the fact that the "removing trailing space"
action is added to the list of undoable actions.

Point 1 can be easily fixed in your code.
Point 2 and 3 show some limits of our framework:

- we should add a "pre-saving" signal for all the plugins that want to
modify the buffer before it is saved (we need to investigate the best
approach to add this feature)

- there is no way to add an action to the stack of undoable actions and
force it to merge with the top of the stack (we need to add suport for
non-interactive actions).


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]