<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Remove &quot;save file&quot; prompt?]]></title><description><![CDATA[<p dir="auto">Hi everyone,</p>
<p dir="auto">I’ve had an absolute blast getting Notepad++ configured, and the amount of flexibility and solutions has me amazed.</p>
<p dir="auto">However, I have one issue that plagues me: <strong>is there a way to stop the “save file: &lt;filename&gt;” prompt from appearing if clearing a singular file?</strong></p>
<p dir="auto">Context: I have a setup for users to read data from an XML file, all setup is good there. My catch is, to make it tolerable, I’ve got it set so it automatically reformats the file. I <em>do not</em> want to save these modifications, but I foresee users complaining about how they have to press No constantly after “not modifying anything”.</p>
<p dir="auto">Has anyone found a solution for this before? Running a relatively fresh install of 8.5 with XML Tools and Python Script, with a few visual modifications. Nothing I couldn’t tweak back into place if necessary! Also, if this is just something that can’t be done, I understand it’s a bit of an odd request. Thank you!</p>
]]></description><link>https://community.notepad-plus-plus.org/topic/24252/remove-save-file-prompt</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Apr 2026 09:38:08 GMT</lastBuildDate><atom:link href="https://community.notepad-plus-plus.org/topic/24252.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Mar 2023 20:01:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Sat, 18 Mar 2023 13:25:02 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said in <a href="/post/84927">Remove “save file” prompt?</a>:</p>
<blockquote>
<p dir="auto">STOP!  You’re doing it wrong!<br />
Every time you run that script, you put another callback in place.</p>
</blockquote>
<p dir="auto">So let’s explore this a bit further.</p>
<p dir="auto">Create a script much like the earlier one in this thread:</p>
<pre><code class="language-py"># -*- coding: utf-8 -*-
from __future__ import print_function
from Npp import *

console.show()

print('user ran the script! (let us flash the screen for fun)')
editor.flash(250)

def BufferActivated(args):
    print('system-generated buffer activated!  tab:', notepad.getCurrentFilename().rsplit('\\', 1)[-1])

notepad.callback(BufferActivated, [NOTIFICATION.BUFFERACTIVATED])
</code></pre>
<p dir="auto">Run it once via the <em>Plugins</em> &gt; <em>Python Script</em> &gt; <em>Scripts</em> menu.  Then click on different tabs, get something like this as output in the PythonScript console window:</p>
<pre><code class="language-txt">user ran the script! (let us flash the screen for fun)
system-generated buffer activated!  tab: new 3
system-generated buffer activated!  tab: new 1
system-generated buffer activated!  tab: new 2
system-generated buffer activated!  tab: new 3
</code></pre>
<p dir="auto">All good.  Now run the script 3 more times from the <em>Plugins</em> &gt; <em>Python Script</em> &gt; _Run Previous Script() _ menu.</p>
<p dir="auto">Now select a few different tabs (I did same sequence as above) to obtain:</p>
<pre><code class="language-txt">user ran the script! (let us flash the screen for fun)
user ran the script! (let us flash the screen for fun)
user ran the script! (let us flash the screen for fun)
system-generated buffer activated!  tab: new 3
system-generated buffer activated!  tab: new 3
system-generated buffer activated!  tab: new 3
system-generated buffer activated!  tab: new 3
system-generated buffer activated!  tab: new 1
system-generated buffer activated!  tab: new 1
system-generated buffer activated!  tab: new 1
system-generated buffer activated!  tab: new 1
system-generated buffer activated!  tab: new 2
system-generated buffer activated!  tab: new 2
system-generated buffer activated!  tab: new 2
system-generated buffer activated!  tab: new 2
system-generated buffer activated!  tab: new 3
system-generated buffer activated!  tab: new 3
system-generated buffer activated!  tab: new 3
system-generated buffer activated!  tab: new 3
</code></pre>
<p dir="auto">As one can see, each time you switch a tab now, the callback gets called <em>FOUR</em> times!  That’s because the script was run 4 times, and 4 separate callback functions were registered.  It doesn’t matter that it was the “<em>same</em>” function that was registered each time.</p>
<p dir="auto">How does one avoid/prevent this kind of thing from happening?  Well, <em>don’t</em> run the script multiple times.  But, accidents happen, so change the <em>code</em> to protect yourself.  But how?</p>
<p dir="auto">The changed script below shows how I like to do it (there are certainly other ways to achieve it):</p>
<pre><code class="language-py"># -*- coding: utf-8 -*-
from __future__ import print_function
from Npp import *

console.show()

print('user ran the script! (let us flash the screen for fun)')
editor.flash(250)

def BufferActivated(args):
    print('system-generated buffer activated!  tab:', notepad.getCurrentFilename().rsplit('\\', 1)[-1])

# --- vvv --- differences from original script are below --- vvv ---

try:
    i_am_installed
except NameError:
    notepad.callback(BufferActivated, [NOTIFICATION.BUFFERACTIVATED])
    i_am_installed = True
else:
    print('callback is already installed!')
</code></pre>
<p dir="auto">The effect should be somewhat self-explanatory from the code.  If you try the multiple runs experiment with this new version of the script, you shouldn’t see multiple buffer-activated processing when tabs are switched in the Notepad++ UI.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84960</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84960</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Sat, 18 Mar 2023 13:25:02 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Sat, 18 Mar 2023 04:44:00 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> said in <a href="/post/84877">Remove “save file” prompt?</a>:</p>
<blockquote>
<p dir="auto">I think <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/5990">@TBugReporter</a> only remembers this function because he <em>didn’t</em> like my usage of it in a previously published script. :-)</p>
</blockquote>
<p dir="auto">No, that wasn’t it; I just wasn’t expecting the result of adding this to the script.  (My latest version of <a href="https://community.notepad-plus-plus.org/topic/23749/list-of-free-keyboard-shortcuts">that script</a> has this as a configurable option.  I haven’t published my version because I still feel it’s not ready for prime time.)</p>
<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/27873">@BrunchTime</a> said in <a href="/post/84916">Remove "save file" prompt?</a>:</p>
<blockquote>
<p dir="auto">I did, however, call that function before running the pretty print as I wanted to be sure that any modifications made would not be saved.</p>
</blockquote>
<p dir="auto">This was exactly the <em>wrong</em> thing to do, because every change you make <em>unsets</em> this.  As you’ve found out, you have to do this <em>after</em> you’ve made all your changes.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84947</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84947</guid><dc:creator><![CDATA[TBugReporter]]></dc:creator><pubDate>Sat, 18 Mar 2023 04:44:00 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Fri, 17 Mar 2023 19:00:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/27873">@BrunchTime</a></p>
<p dir="auto">STOP!  You’re doing it wrong!</p>
<p dir="auto">Every time you run that script, you put another callback in place.<br />
If you run it twice, then after that when you switch tabs, the callback function will run twice.  If you manually run the script <em>n</em> times, the callback function will run <em>n</em> times when you switch tabs.  Do you really want the same functionality to run <em>n</em> times over when you switch tabs?  No, <em>once</em> is enough when you switch tabs.</p>
<p dir="auto">If you want additional functionality, to run “on demand”, put that in a separate script, and then run <em>that</em> script at the right time.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84927</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84927</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 17 Mar 2023 19:00:45 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Fri, 17 Mar 2023 17:06:02 GMT]]></title><description><![CDATA[<p dir="auto">And so far I’ve found one quirk I needed to iron out. Probably due to my lack of understanding how the buffer works and the function, this only applies when an active tab is switched to, not when Notepad++ is opened. This also applies to opening files directly, where it would not format until another tab is opened. Of course, this poses an issue for me as I can very quickly see users complaining about how it doesn’t format correctly as I see them opening one file, closing Notepad++, then immediately opening a completely different file.</p>
<p dir="auto">I did find out that (sloppily) copying the same to run a singular if command works, and the <code>BufferActivated</code> function still runs for any new tabs, thus solving my issue! I’m posting this here in hopes that someone else might get some use out of it, or an opportunity for someone to optimize the code.</p>
<pre><code>from Npp import notepad, editor, NOTIFICATION, LANGTYPE

if notepad.getLangType() == LANGTYPE.XML and editor.getProperty('already_formatted') == '':
        notepad.runPluginCommand('XML Tools','Pretty print - indent attributes')
        editor.setProperty('already_formatted', '1')
        editor.setSavePoint()

def BufferActivated(args):
    if notepad.getLangType() == LANGTYPE.XML and editor.getProperty('already_formatted') == '':
        notepad.runPluginCommand('XML Tools','Pretty print - indent attributes')
        editor.setProperty('already_formatted', '1')
        editor.setSavePoint()
        
notepad.callback(BufferActivated, [NOTIFICATION.BUFFERACTIVATED])
</code></pre>
<p dir="auto">The catch here is that it runs a bit too often. Good if you’re looking to look at a single file, not good if you’re looping between multiple XML files. Still gets the job done though!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84926</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84926</guid><dc:creator><![CDATA[BrunchTime]]></dc:creator><pubDate>Fri, 17 Mar 2023 17:06:02 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Fri, 17 Mar 2023 13:43:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> Thank you again for all the information! Fortunately I’ve been writing some basic Powershell scripts recently so I’m getting the hang of this. Your explanation made total sense when I realized that it needed to go into the executed part of the if statement, if that makes sense. This is now working exactly as I hoped, which amazes me. I did, however, call that function(?) before running the pretty print as I wanted to be sure that any modifications made would not be saved. The undo button has been proving that!</p>
<p dir="auto">EDIT: Almost forgot to mention, this is part of my <a href="http://startup.py" rel="nofollow ugc">startup.py</a> script, so this runs by default <em>and</em> works automatically as a result once set to “ATSTARTUP” for the initialization.</p>
<p dir="auto">EDIT 2: Apparently I misconfigured this, and Alan was indeed right, it should be <em>after</em> the setProperty line. Code is updated, realized my mistake after I re-tested it just now.</p>
<p dir="auto">Also, for those interested in exactly what the code looks like:</p>
<pre><code>from Npp import notepad, editor, NOTIFICATION, LANGTYPE

def BufferActivated(args):
    if notepad.getLangType() == LANGTYPE.XML and editor.getProperty('already_formatted') == '':
        notepad.runPluginCommand('XML Tools','Pretty print - indent attributes')
        editor.setProperty('already_formatted', '1')
        editor.setSavePoint()
        
notepad.callback(BufferActivated, [NOTIFICATION.BUFFERACTIVATED])
</code></pre>
<p dir="auto">Thank you so much for your time, I think my users are going to be very pleased!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84916</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84916</guid><dc:creator><![CDATA[BrunchTime]]></dc:creator><pubDate>Fri, 17 Mar 2023 13:43:06 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Fri, 17 Mar 2023 13:22:57 GMT]]></title><description><![CDATA[<p dir="auto">I should have mentioned that “buffer activated” also occurs when you open a file.  There’s a “file opened” callback, but my experience with that one is that you can’t really do much there, because the tab with data that you want to act on isn’t fully formed at that point.  You have to wait for “buffer activated” to be signalled (from N++).</p>
<p dir="auto">So after you’ve run the script ONCE, then the logic should run anytime you switch the active tab, or when you open a file.  Since the script has logic to only do stuff when the tab is an XML file, nothing will happen in those scenarios where you are dealing with a non-XML file.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84912</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84912</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Fri, 17 Mar 2023 13:22:57 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Thu, 16 Mar 2023 20:36:57 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/27873">@BrunchTime</a></p>
<p dir="auto">Hmmmmmmmmmmmmmmmmmm.  How to explain this to the uninitiated…?</p>
<p dir="auto">Forget where you put <code>editor.setSavePoint()</code> for a moment; consider the remainder of the script.</p>
<p dir="auto">When you run that script, it becomes “resident”.  You don’t have to keep running that script when you want the “pretty print” stuff to execute, it just happens whenever you change tabs in Notepad++, after you’ve run the script <em>ONCE</em>.</p>
<p dir="auto">It runs on the tab you make active.  Hence “buffer activated – callback”.  Get it?  It’s code that gets called when a certain thing happens, specifically, when activating a tab.  There are all kinds of other callbacks, e.g. when a file is saved by the user, when a file is renamed by the user, etc.</p>
<p dir="auto">Now the smart thing to do might be to put the script into user <a href="http://startup.py" rel="nofollow ugc">startup.py</a>, or call the script from there.  You can find more details about script setup and use <a href="https://community.notepad-plus-plus.org/topic/23039/faq-desk-how-to-install-and-run-a-script-in-pythonscript">HERE</a>.  But this is off topic from your original question.</p>
<p dir="auto">So if you want the <code>setSavePoint()</code> call to do its stuff at the same time (well, right after) as the “pretty print” (not saying you do, I’m not really following your exact need), then you should put the <code>editor.setSavePoint()</code> call directly below the <code>setProperty</code> line, and indented to the same level.</p>
<p dir="auto">That way it will happen when a tab is activated, right after the pretty printing.  But again, I don’t know for sure that’s what you want.</p>
<p dir="auto">Seriously, this stuff isn’t that hard to “read” and know what it does.  Now, if you had to write it from scratch, that’s a different story.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84891</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84891</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 16 Mar 2023 20:36:57 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Thu, 16 Mar 2023 19:52:31 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a></p>
<pre><code>from Npp import notepad, editor, NOTIFICATION, LANGTYPE

editor.setSavePoint()

def BufferActivated(args):
    if notepad.getLangType() == LANGTYPE.XML and editor.getProperty('already_formatted') == '':
        notepad.runPluginCommand('XML Tools','Pretty print - indent attributes')
        editor.setProperty('already_formatted', '1')
        
notepad.callback(BufferActivated, [NOTIFICATION.BUFFERACTIVATED])
</code></pre>
<p dir="auto">Really, the only difference between the original and mine is an update to the pretty print function here to run the updated version of the command, and the addition of <code>editor.setSavePoint()</code>. But, even then it doesn’t act as intended. Pretty print runs, but still prompts for save.</p>
<p dir="auto">I know for a fact I’m missing something. Figured it should be after the <code>from</code> in this code though. Thanks for your help!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84889</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84889</guid><dc:creator><![CDATA[BrunchTime]]></dc:creator><pubDate>Thu, 16 Mar 2023 19:52:31 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Thu, 16 Mar 2023 18:26:50 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/27873">@BrunchTime</a></p>
<blockquote>
<p dir="auto">The function works as I’d hoped though, just not when as part of a script. Can’t help but feel I’m missing something!</p>
</blockquote>
<p dir="auto">I don’t get the feeling your customized script is going to be huge, so how about posting it?  Maybe something will jump out.</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84888</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84888</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 16 Mar 2023 18:26:50 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Thu, 16 Mar 2023 18:08:07 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/7377">@Alan-Kilborn</a> I appreciate the elaboration! I was able to test out the functionality of it, but unfortunately I can’t quite get it to work.</p>
<p dir="auto">Anyways, I’ll admit, I borrowed a script that was made by Eko palypse, found at the <a href="https://community.notepad-plus-plus.org/post/37705">bottom of this thread.</a> I made one tiny modification to it for modern XML Tools standards. This portion works beautifully.</p>
<p dir="auto">Having tested it, running <code>editor.setSavePoint()</code> direct from the console works, but appears to have no effect when this script is run. I can tell as it both prompts me, and the editor specifies that changes haven’t been saved on the side. I know it imports the editor module as well, so I’m guessing some context somewhere.</p>
<p dir="auto">The function works as I’d hoped though, just not when as part of a script. Can’t help but feel I’m missing something!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84886</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84886</guid><dc:creator><![CDATA[BrunchTime]]></dc:creator><pubDate>Thu, 16 Mar 2023 18:08:07 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Thu, 16 Mar 2023 13:45:49 GMT]]></title><description><![CDATA[<p dir="auto">As <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/5990">@TBugReporter</a> linked, just call the <code>editor.setSavePoint()</code> function to make the editor think that the current tab contents have been saved.  The tab icon will change state to reflect this.  Needless to say, be careful when using this.</p>
<p dir="auto">I think <a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/5990">@TBugReporter</a> only remembers this function because he <em>didn’t</em> like my usage of it in a previously published script. :-)</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84877</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84877</guid><dc:creator><![CDATA[Alan Kilborn]]></dc:creator><pubDate>Thu, 16 Mar 2023 13:45:49 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Thu, 16 Mar 2023 13:32:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="https://community.notepad-plus-plus.org/uid/5990">@TBugReporter</a> said in <a href="/post/84861">Remove “save file” prompt?</a>:</p>
<blockquote>
<p dir="auto">yes</p>
</blockquote>
<p dir="auto">Ooh, fascinating. Good thing I’ve already got some work done with another basic Python script. Definitely not my area of expertise but I’ll give it a shot.</p>
<p dir="auto">Thank you so much for showing me this!</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84875</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84875</guid><dc:creator><![CDATA[BrunchTime]]></dc:creator><pubDate>Thu, 16 Mar 2023 13:32:18 GMT</pubDate></item><item><title><![CDATA[Reply to Remove &quot;save file&quot; prompt? on Thu, 16 Mar 2023 00:14:00 GMT]]></title><description><![CDATA[<p dir="auto">With Python, <a href="https://npppythonscript.sourceforge.net/docs/latest/scintilla.html?highlight=setsavepoint#Editor.setSavePoint" rel="nofollow ugc">yes</a> - you essentially tell N++ that it’s already been saved, so it doesn’t have to ask about saving it (again).</p>
]]></description><link>https://community.notepad-plus-plus.org/post/84861</link><guid isPermaLink="true">https://community.notepad-plus-plus.org/post/84861</guid><dc:creator><![CDATA[TBugReporter]]></dc:creator><pubDate>Thu, 16 Mar 2023 00:14:00 GMT</pubDate></item></channel></rss>