123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104open!Core_kernelopen!Importletadvice_add=Funcall.("advice-add"<:Symbol.t@->Symbol.t@->Symbol.t@->returnnil);;letadd_predefined_functionadvice_name~for_function=advice_addfor_functionQ.K.aroundadvice_name;;letadd_internaladvice_namehere~for_function?docstring?interactive?should_profilesync_or_asyncf=Defun.defunadvice_namehere?docstring?interactive?should_profile(Defun.Returns.returnssync_or_asyncValue.Type.value)(letopenDefun.Let_syntaxinlet%map_open()=return()andinner=required"inner"valueandrest=rest"rest"valueinfinnerrest);add_predefined_functionadvice_name~for_function;;letaround_valuesadvice_nameheresync_or_async?docstring~for_function?interactive?should_profilef=add_internaladvice_namehere?docstring~for_function?interactive?should_profilesync_or_async(funinnerrest->f(Value.funcallN?should_profileinner)rest);;moduleOn_parse_error=structtypet=|Allow_raise|Call_inner_function[@@derivingsexp_of]endletaround_funcalladvice_namehere?docstring~for_function?interactive?(on_parse_error=On_parse_error.Allow_raise)?should_profilefuncallf=add_internaladvice_namehere~for_function?docstring?interactive?should_profileSync(funinnerrest->Funcall.Private.applyfuncall(f(Funcall.Private.wrap_unrolledfuncallinner))rest~on_parse_error:(match(on_parse_error:On_parse_error.t)with|Allow_raise->raise|Call_inner_function->funexn->Echo_area.inhibit_messagesSync(fun()->message_s[%message"Ignoring advice that failed to parse its arguments."~_:(here:Source_code_position.t)~_:(exn:exn)]);Value.funcallNinnerrest));;letadvice_remove=Funcall.("advice-remove"<:Symbol.t@->Symbol.t@->returnnil)letremoveadvice_name~for_function=advice_removefor_functionadvice_name