From 209ae8f20ad3a730a6bc766b17d49a64276fdd53 Mon Sep 17 00:00:00 2001 From: Camille Dejoye Date: Sat, 13 Jun 2020 12:46:57 +0200 Subject: [PATCH] doc: update the doc for the order of hooks --- doc/argwrap.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/doc/argwrap.txt b/doc/argwrap.txt index 8ca10f1..d5dffe7 100644 --- a/doc/argwrap.txt +++ b/doc/argwrap.txt @@ -227,6 +227,18 @@ Global hooks will be executed before filetype ones. Global and filetype hooks are sorted by the |globpath()| function. Meaning you can control the execution order of the hooks by prefixing them with a priority. +Post hooks order is reversed in order to keep the execution order logical. + +For example if there two hooks named `000_cursor` and `200_anything` , the +cursor hook being responsible to preserve the cursor position it must be +executed first to ensure no modification of the cursor position has been done +yet so it receive the lowest priority. +The execution stack for a wrap operation would then be: + - `000_cursor#pre_wrap` + - `000_anything#pre_wrap` + - `wrap operation` + - `000_anything#post_wrap` + - `000_cursor#post_wrap` An important things to know when writing a new hook is that calling an