I love Programmer's Notepad and have been using it for quite some time, but it has always bugged me that there is no option to remove trailing whitespace when saving documents. After browsing the forums and checking out the extension documentation I installed PyPN and wrote a very simple script to remove trailing whitespace when the document is saved. I have mapped this to Ctrl+S and the original save function to Ctrl+Shift+S.
If anyone else wants this functionality, you can follow the on-site instructions to install Python and PyPN and then place this script in the scripts directory as a .py file. Many thanks for making PN so extensible!
import pn
import scintilla
from pypn.decorators import script
@script("Remove Trailing Whitespace")
def RemoveTrailingWhitespace():
editor = scintilla.Scintilla(pn.CurrentDoc())
editor.BeginUndoAction()
options = pn.GetUserSearchOptions()
options.FindText = "\\s+$"
options.ReplaceText = ""
options.UseSlashes = True
options.UseRegExp = True
pn.CurrentDoc().ReplaceAll(options)
pn.CurrentDoc().Save(pn.CurrentDoc().FileName, 1)
editor.EndUndoAction()