GNOME Bugzilla – Bug 305816
New plugin: remove trailing whitespace
Last modified: 2020-11-24 10:17:30 UTC
The feature I miss the most from gedit is the ability to remove trailing whitespace from files. Source files with a lot of trailing whitespace are simply unclean ;)
Created attachment 46998 [details] [review] complete patch And just to show how badly I want this feature, here is a patch completely implementing said feature. It also adds the necessary code for having this function configurable. The only thing missing is translation of the new text associated with the configuration. I don't know all the languages supported by gedit so I'm afraid I can't do this myself ;) Please review and commit.
Comment on attachment 46998 [details] [review] complete patch Thank you for the patch. We will review it as soon as possible.
*poke* How's that review going? :)
Created attachment 51057 [details] [review] complete patch Patch updated to latest release of gedit.
confirming and raising priority.
Lowering priority, since even if with a patch, this is a request for enanchement so we cannot get it in 2.12. Pierre, Paolo Maggi is currently on vacation that's why he didn't comment on the patch yet. I gave the patch a quick look and the way you strip whitespaces is a bit dubious to me (many memmoves, using isspace instead of g_unichar_isspace etc), but I may be wrong... More importantely I'm not sure we want to add this option as yet another toggle in the preferences dialog: we are really trying to keep options to a minimumn and if possible reduce the ones we already have there. Maybe this functionality should be implemented in a plugin. Last but not least, I suggest you to work against the new_mdi cvs branch of gedit, since that's where all the new developement will take place. See http://live.gnome.org/Gedit/NewMdi. Thanks again for the patch and sory for the untimely and small feedback :/
I chose not to be clever about the algorithm until it proves to be annoyingly slow. As for not using g_unichar_isspace it's because I wasn't aware of the function. Afraid I don't know glib that well... I can fully agree with the sentiment to keep the preferences window clutter free. I'd consider this a basic feature for a programmers editor, but in the end you make that decision. I found it easier to hack directly in gedit instead of learning the plug-in API. I wasn't aware a new development branch was started but I'll have a look. Has the plug-in API changed there?
Yep, the plugin system changed completely (and should be easier), that's why I mentioned alongside the suggestion of turning it into a plugin. The plugin interface is not very well documented yet, but there is a script in tools/ that generates the plugin scheleton code for you and then you can look at one of the plugins which have already been ported to the new interface.
Created attachment 160184 [details] [review] Implement saving without trailing spaces This patch does not remove the spaces but prevents them from being saved. However not removing the spaces is actually nice because it allows you to continue working in the editor without its contents changing when you save. Also, this avoids any issues with the undo manager.
Does your patch remove trailing spaces from all lines in the file, or only from modified lines?
I'm not sure about this, but I think the patch needs an update (purely based on the date and the number of changes in gedit lately). Btw, I tend to agree with Paolo's (fairly ancient) comment #8, maybe it would be wise to have this implemented as a plugin.
The feature should be implemented in GtkSourceView in my opinion, since it is useful for lots of text editors. See bug #736585.
Mass-closing of all gedit-plugins bugzilla tickets. Special "code" to find again all those gedit-plugins bugzilla tickets that were open before the mass-closing: 2bfe1b0590a78457e1f1a6a90fb975f5878cb60064ccfe1d7db76ca0da52f0f3 By searching the above sha256sum in bugzilla, the gedit contributors can find again the tickets. We may be interested to do so when we work on a specific area of the code, to at least know the known problems and possible enhancements. We do this mass-closing because bugzilla.gnome.org is being replaced by gitlab.gnome.org.