From 88a2b622df50d5f9c85a3912826ae93b603992a0 Mon Sep 17 00:00:00 2001 From: liljencrantz <liljencrantz@gmail.com> Date: Thu, 17 Jan 2008 08:25:31 +1000 Subject: [PATCH] Add more documentation on events darcs-hash:20080116222531-75c98-ef30dabc492d7883dbb620c40ef95152469057a3.gz --- doc_src/function.txt | 6 ++++++ doc_src/index.hdr.in | 1 + 2 files changed, 7 insertions(+) diff --git a/doc_src/function.txt b/doc_src/function.txt index 7bf7ced20..829530f6e 100644 --- a/doc_src/function.txt +++ b/doc_src/function.txt @@ -6,6 +6,7 @@ \subsection function-description Description - <code>-d DESCRIPTION</code> or \c --description=DESCRIPTION is a description of what the function does, suitable as a completion description +- <code>-e</code> or <code>--on-event EVENT_NAME</code> tells fish to run this function when the specified named event is emitted. Fish internally generates named events e.g. when showing the prompt. - <code>-j PID</code> or <code> --on-job-exit PID</code> tells fish to run this function when the job with group id PID exits. Instead of PID, the string 'caller' can be specified. This is only legal when in a command substitution, and will result in the handler being triggered by the exit of the job which created this command substitution. - <code>-p PID</code> or <code> --on-process-exit PID</code> tells fish to run this function when the fish child process with process id PID exits - <code>-s</code> or <code>--on-signal SIGSPEC</code> tells fish to run this function when the signal SIGSPEC is delivered. SIGSPEC can be a signal number, or the signal name, such as SIGHUP (or just HUP) @@ -26,6 +27,11 @@ will write <code>hello</code> whenever the user enters \c hi. If the user enters any additional arguments after the function, they are inserted into the environment <a href="index.html#variables-arrays">variable array</a> argv. +By using one of the event handler switches, a function can be made to run automatically at specific events. The user may generate new events using the <a href='#emit">emit</a> builtin. Fish generates the following named events: + +- \c fish_prompt, which is emitted whenever a new fish prompt is about to be displayed +- \c fish_command_not_found, which is emitted whenever a command lookup failed + \subsection function-example Example <pre> diff --git a/doc_src/index.hdr.in b/doc_src/index.hdr.in index 3ca0dbbdd..51d5b32d7 100644 --- a/doc_src/index.hdr.in +++ b/doc_src/index.hdr.in @@ -1266,6 +1266,7 @@ specific event takes place. Events that can trigger a handler currently are: - When a process or job exits - When the value of a variable is updated - When the prompt is about to be shown +- When a command lookup fails Example: