Closed aplteam closed 5 years ago
Brings up the question of what to do next. I've now added error trapping but at the point the error occurs it's necessary to decide whether or not to stay in the editor and/or continue acre's normal processing to write the file. That decision is supposed to be made by the exit function which has failed for whatever reason. We could treat it as if the function didn't exist but it might well have got through half of its process before hitting some file error. The fact that the session is unresponsive at that point is because the editor is stll active and according to dyalog some external process is running:
But:
forgets to specify a left argument
is something a developer might do once in any situation. To add complex processing to decide whether that mistake has been made every time the function runs might be considered overkill? If the function is a dfn or specifies {left}
it can be called dyadically and its arguments ignored.
We could allow the editor to fix the item being edited and terminate with a message to the session that the error has occurred but the item has not been saved.
User exit function is currently called after dyalog has fixed the item but before acre has saved it to file.
as currently defined it takes:
and is expected to return:
Agreed at go-to-meeting 2019-06-25:
matters arising
Does this obviate the need for the old & new values in the right argument and the different results?
I think so.
Would it be useful if a non-empty result were treated as one or more log-messages?
Excellent idea.
Setting the exit fn could also be implemented as an API function ⎕SE.acreAPI.setexit fqn [say] being easier to call in a startup routine than ⎕SE.UCMD 'acre.setexit fqn'
Yes.
Any errors in the exit function should be trapped, and an according entry should go into the log.
Noted. Thanks. On to it. Currently working to call new command ]AfterSave
that allows for easy addition of ]BeforeSave
if deemed necessary.
]aftersave #.new.value
#.old.value
]aftersave
#.new.value
⎕se.acreAPI.aftersave '#.other.value'
#.new.value
⎕se.acreAPI.aftersave ''
#.other.value
Default will be ''
at start of session. ]OpenProject
will apply current value to project if not overridden by project config file as AfterSave←'#.project.specific'
.
Also note Norbert's good idea that a single callback could be tailored to behave differently per project by reference to an ad-hoc variable in the project config.
The documentation states that anu user exit function must accept a left and a right argument.
However, in case one forgets to specify a left argument acre crashes and the APL session becomes unresponsive:
I think that's too harsh. acre should figure out and when the function is monadic or even niladic call it accordingly.
Same for the explicit result of the function: if it does not return a result that should be accepted.