Next Previous Contents

79. SLang_run_hooks


Run a user-defined hook with arguments


int SLang_run_hooks (char *fname, unsigned int n, ...)


The SLang_run_hooks function may be used to execute a user-defined function named fname. Before execution of the function, the n string arguments specified by the variable parameter list are pushed onto the stack. If the function fname does not exist, SLang_run_hooks returns zero; otherwise, it returns 1 upon successful execution of the function, or -1 if an error occurred.


The jed editor uses SLang_run_hooks to setup the mode of a buffer based on the filename extension of the file associated with the buffer:

      char *ext = get_filename_extension (filename);
      if (ext == NULL) return -1;
      if (-1 == SLang_run_hooks ("mode_hook", 1, ext))
        return -1;
      return 0;
See Also

SLang_is_defined, SLang_execute_function

Next Previous Contents