The problem:
I generate text data on the fly and pipe it into a SciTE session in
order to display them. Now this data can be regenerated quickly and I
don't want to save it, so I'd like to close SciTE without being forced
to answer whether I want to save the data every time.
Is there an option/trick to suppress the "are you sure" dialog even when
there is unsaved data in a buffer and the data must be discarded by default.
The option "are.you.sure" only handles the case of saving by default.
I work on Windows XP - a non-cross-platform solution would be acceptable.
Note: saving in a temp file is not an option - I don't want anything to
be saved anywhere, even if temporarily.
Thanks in advance for any suggestion.
--
Lorenzo
Make a Lua function doing only:
editor:SetSavePoint()
Associate a keyboard shortcut to it.
If you don't want any intervention, you might try to put it in one of the OnXxx events,
eg. OnBeforeSave, with are.you.sure=0 (auto save, but won't save? to try...).
--
Philippe Lhoste
-- (near) Paris -- France
-- http://Phi.Lho.free.fr
-- -- -- -- -- -- -- -- -- -- -- -- -- --
Thanks Philippe for the suggestion.
I hoped for a simpler solution. Not that I'm scared of a little bit of
Lua, but I thought this was a fairly common need, which probably
deserves some support (a new option? A new command line switch?).
Cheers
--
Lorenzo
I've tried to apply your suggestion, but to no avail.
It seems that the dialog asking to save changes of an "untitled" buffer
cannot be avoided.
The only event that seemed to be triggered _after_ the untitled buffer
has been updated with the text coming from stdin is OnSavePointLeft.
I tried setting are.you.sure=0 and defining:
function OnSavePointLeft()
print( 'save point left: ' .. tostring(editor.Modify) ) --> true
editor:SetSavePoint()
print( 'save point left: ' .. tostring(editor.Modify) ) --> false
end
That handler gets actually called (the calls to print above show that),
but when trying to close the buffer with Ctrl+W (or other means), the
dialog still pops-up. Note that the "dirty" status of the tab is still
not cleared (it still shows an asterisk beside "untitled" on the buffer
tab).
I also tried with OnClose, but that handler seems to get called _after_
the dialog pops-up.
I also tried this approach on a clean "installation" (reminder: SciTE
2.25 on WinXP), to avoid possible interference with my usual "nasty"
setup. No success either.
Any suggestion anyone?
I tried the good idea of Robin: I made the following Lua function:
function ForceClose()
editor:SetSavePoint()
scite.MenuCommand(IDM_CLOSE)
end
then I added the following command settings:
# Close current buffer without asking
command.name.4.*=&Force Close
command.4.*=ForceClose
command.shortcut.4.*=Ctrl+Shift+W
command.mode.4.*=subsystem:lua,savebefore:no
And when I hit Ctrl+Shift+W, it closes the current tab without asking questions, even if
the buffer is dirty and/or unsaved.
The only drawback is that I have to waste a user command. I begin to run
short of them.(I use commands from #1 to #20 for lexer-specific commands
and reserve #21 through #50 for general purpose commands.)
This notwithstanding, I'm still puzzled about why it seems to be
impossible to do in a OnXXX event handler.
Cheers!
--
Lorenzo
Yes. 50 numbers is very small. Satisfies only the ascetics ;)
> This notwithstanding, I'm still puzzled about why it seems to be
> impossible to do in a OnXXX event handler.
I wanted to give a working example:
function OnMenuCommand(msg, source)
if msg == IDM_QUIT then
editor:SetSavePoint()
end
end
but I remembered that there OnMenuCommand is only with scite-ru.
Ask Neil. I am willing to give the patch.
--
mozers
<http://scite-ru.org>