]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/todo/be_more_selective_about_running_hooks.mdwn
hmmmm
[git.ikiwiki.info.git] / doc / todo / be_more_selective_about_running_hooks.mdwn
1 [[!template  id=gitbranch branch=chrismgray/exclusive-hooks author="[[chrismgray]]"]]
3 Sometimes plugins register a function with `hook`, but they only want
4 the function called with the content that they know how to deal with.
5 Normally, this means that they call `pagetype` first thing in the
6 function, determine if they know how to deal with the content, and
7 only do anything if they do.  
9 This is a bit wasteful in itself, but for external plugins, it's
10 really bad.  For functions like `scan` and `linkify`, where the entire
11 page is sent back and forth over `stdout` and `stdin`, it really slows
12 things down.  
14 Thus, I propose that there be a new optional parameter to `hook` that
15 tells it that the function should only be called for files whose type
16 is the same as the id of the plugin calling `hook`.  I have called
17 this parameter `exclusive` in my branch, but this might not be the
18 best name.
20 [[!tag patch]]
22 > It's an interesting idea, but it might be more useful if it was more generalized, say, by making it a filter, where the parameter is a regexp.
23
24 > --[[KathrynAndersen]]