File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -470,6 +470,14 @@ Major performance enhancements have been added:
470470
471471 (Contributed by Jake McGuire and Antoine Pitrou; :issue: `5084 `.)
472472
473+ IDLE
474+ ====
475+
476+ * IDLE's format menu now provides an option to strip trailing whitespace
477+ from a source file.
478+
479+ (Contributed by Roger D. Serwy; :issue: `5150 `.)
480+
473481Build and C API Changes
474482=======================
475483
Original file line number Diff line number Diff line change 1+ 'Provides "Strip trailing whitespace" under the "Format" menu.'
2+
3+ __author__ = "Roger D. Serwy <roger.serwy at gmail.com>"
4+
5+ class RstripExtension :
6+
7+ menudefs = [
8+ ('format' , [None ,
9+ ('Strip trailing whitespace' , '<<do-rstrip>>' ),
10+ ]),]
11+
12+ def __init__ (self , editwin ):
13+ self .editwin = editwin
14+ self .editwin .text .bind ("<<do-rstrip>>" , self .do_rstrip )
15+
16+ def do_rstrip (self , event = None ):
17+
18+ text = self .editwin .text
19+ undo = self .editwin .undo
20+
21+ undo .undo_block_start ()
22+
23+ end_line = int (float (text .index ('end' ))) + 1
24+ for cur in range (1 , end_line ):
25+ txt = text .get ('%i.0' % cur , '%i.0 lineend' % cur )
26+ cut = len (txt .rstrip ())
27+ text .delete ('%i.%i' % (cur , cut ), '%i.0 lineend' % cur )
28+
29+ undo .undo_block_stop ()
Original file line number Diff line number Diff line change @@ -86,3 +86,9 @@ bgcolor=LightGray
8686fgcolor=Black
8787[CodeContext_bindings]
8888toggle-code-context=
89+
90+ [RstripExtension]
91+ enable=1
92+ enable_shell=0
93+ enable_editor=1
94+
Original file line number Diff line number Diff line change @@ -658,6 +658,7 @@ Nick Seidenman
658658Žiga Seilnach
659659Fred Sells
660660Jiwon Seo
661+ Roger D, Serwy
661662Jerry Seutter
662663Denis Severson
663664Ian Seyer
Original file line number Diff line number Diff line change @@ -262,6 +262,9 @@ Library
262262- Issue #5311: bdist_msi can now build packages that do not depend on a
263263 specific Python version.
264264
265+ - Issue #5150: IDLE's format menu now has an option to strip trailing
266+ whitespace.
267+
265268- Issue #5940: distutils.command.build_clib.check_library_list was not doing
266269 the right type checkings anymore.
267270
You can’t perform that action at this time.
0 commit comments