Permalink
Browse files

Merge pull request #12 from drahnr/master

Fixes to make it work with current gnome and cinnamon.
  • Loading branch information...
2 parents cbe7bb1 + 170065b commit 2644c1d73ee70f068f93c3d106721c2ea7516778 @drahnr drahnr committed Dec 1, 2013
Showing with 15 additions and 8 deletions.
  1. +10 −4 README.md
  2. +2 −2 trailsave.plugin
  3. +3 −2 trailsave.py
View
@@ -1,16 +1,15 @@
-**I am no longer maintaining this project. Please contact me if you'd like to take over.**
-
Gedit Trailsave
---------------
A plugin for Gedit 3 to strip trailing whitespace on save.
-This will not work on Gedit 2. You can download the Gedit 2 version here: http://users.tkk.fi/~otsaloma/gedit/
+This will not work on Gedit 2.
* Authors:
* Osmo Salomaa wrote original Gedit 2 plugin
* Jon Leighton ported to Gedit 3
-* Version: 3.1.2
+ * Bernhard Schuster maintainance & fixes
+* Version: 3.3.0
Installation
------------
@@ -21,9 +20,16 @@ Installation
4. Activate the plugin in 'Edit > Preferences'
5. Now, whenever a document is saved, trailing whitepace will be removed
+Issues
+------
+
+Report issues to the [bug tracker on github](https://github.com/jonleighton/gedit-trailsave/issues)
+
+
License
-------
+Copyright (C) 2013 Bernhard Schuster
Copyright (C) 2006-2011 Osmo Salomaa & Jon Leighton
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
View
@@ -1,10 +1,10 @@
[Plugin]
-Loader=python
+Loader=python3
Module=trailsave
IAge=3
Name=Trailsave
Description=Strip trailing whitespace on save
Authors=Osmo Salomaa <otsaloma@cc.hut.fi>, Jon Leighton <j@jonathanleighton.com>
Copyright=Copyright (C) 2006-2011 Osmo Salomaa & Jon Leighton
Website=http://github.com/jonleighton/gedit-trailsave
-Version=3.1.2
+Version=3.3.0
View
@@ -58,15 +58,16 @@ def strip_trailing_spaces(self):
"""
text = self.doc.get_text(self.doc.get_start_iter(), self.doc.get_end_iter(), False)
- text = unicode(text, 'utf-8')
+
+ compiledpattern = re.compile('.*?([ \t]+)$', flags=re.MULTILINE)
start_iter = self.doc.get_start_iter()
end_iter = self.doc.get_start_iter()
line_no = 0 # Last matched line no
last_match_pos = 0 # Last matched position in the string
- for match in re.finditer('.*?([ \t]+)$', text, flags=re.MULTILINE):
+ for match in re.finditer(compiledpattern, text):
# Count the newlines since the last match
line_no += text.count('\n', last_match_pos, match.start())

0 comments on commit 2644c1d

Please sign in to comment.