package ecaml

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

The "advice" feature lets you add to the existing definition of a function, by wrapping around the original function a "piece of advice".

Each piece of advice receives the original function and arguments; its result is returned to the caller as if from the original function.

A function may have multiple pieces of advice, which are composed by nesting earlier advice within later advice.

If async advice is added to an elisp function, that function must be called with run_outside_async or it will raise at runtime. This cannot be detected at compile time because one can add advice at runtime.

(Info-goto-node "(elisp)Advising Functions")

type t
val sexp_of_t : t -> Sexplib0.Sexp.t
val of_function : Symbol.t -> t
val defun_around_values : Symbol.t -> Core.Source_code_position.t -> (Ecaml_value.Value.t, 'a) Sync_or_async.t -> docstring:string -> ?interactive:Defun.Interactive.t -> ?should_profile:bool -> ((Ecaml_value.Value.t list -> Ecaml_value.Value.t) -> Ecaml_value.Value.t list -> 'a) -> t

defun_around_values advice_name here ~docstring f creates advice named advice_name with body f. Compared to defun_around_funcall, defun_around_values provides looser coupling when the advice doesn't need to interact with the arguments or return value of the advised function.

module On_parse_error : sig ... end
val defun_around_funcall : Symbol.t -> Core.Source_code_position.t -> docstring:string -> ?interactive:Defun.Interactive.t -> ?on_parse_error:On_parse_error.t -> ?should_profile:bool -> 'a Ecaml_value.Funcall.t -> ('a -> 'a) -> t

defun_around_funcall provides typeful access to the arguments and return value of the advised function.

val add : t -> to_function:Symbol.t -> unit

(describe-function 'advice-add)

val remove : t -> from_function:Symbol.t -> unit

(describe-function 'advice-remove)

OCaml

Innovation. Community. Security.