Code: Select all
function key_macro()
if is_modified() then
message(macro_tag("$FN") .. " is modified.")
else
message(macro_tag("$FN") .. " is NOT modified.")
end
end
key_macro() -- run the macro
As a follow on to this and assuming I'm doing something wrong, what will the is_modified state be in a file save postfix event? Since it's postfix, it seems like I might have to expect that the modified tag has been reset, which would be a pain, but not entirely unexpected.
What I'm trying to do is to detect whether the file actually needed to be saved before doing my save postfix stuff, since it can be a bit time consuming, much more so than the actual saving of the file locally.
How about in a file SaveAs postfix event? It occurs to me that it is entirely possible to SaveAs an unmodified buffer, creating a new file - would I see is_modified in that case? I'm guessing I would not.
I was doing some testing in my save postfix event code to try to make that determination when I encountered the problem above, so I stripped it down to the minimum code just to make sure it wasn't unique to the save postfix and still had the problem.
Bill Diener