In a plugin I’m working on I’m using the (undocumented) View
class retarget()
method to set a buffer’s path and then using run_command()
to save the buffer, like this:
new_buffer = self.active_window.new_file()
new_buffer.retarget(path)
new_buffer.run_command("save")
Since the user may not have permission to write path
I’d like to be able to check if run_command("save")
succeeded or not. Unfortunately run_command()
does not return a value, is there some other way that I can see if run_command("save")
succeeded from within the plugin?
ST does show a dialog box saying the save failed but my plugin needs to determine whether to proceed or not.
ST also logs the failed save in the console “error: unable to save [path]” along with the specific error message, e.g. “Error: Permission denied”. Perhaps this can be examined somehow?
Thanks.