comparison lispref/modes.texi @ 43264:91a36592ab22

*** empty log message ***
author Stefan Monnier <monnier@iro.umontreal.ca>
date Tue, 12 Feb 2002 19:33:46 +0000
parents 03dd2df2b595
children 8d02880abeaa
comparison
equal deleted inserted replaced
43263:6862a1a4bd8e 43264:91a36592ab22
2204 If the variable's name ends in @samp{-functions} or @samp{-hooks}, 2204 If the variable's name ends in @samp{-functions} or @samp{-hooks},
2205 then the value is a list of functions, but it is abnormal in that either 2205 then the value is a list of functions, but it is abnormal in that either
2206 these functions are called with arguments or their values are used in 2206 these functions are called with arguments or their values are used in
2207 some way. You can use @code{add-hook} to add a function to the list, 2207 some way. You can use @code{add-hook} to add a function to the list,
2208 but you must take care in writing the function. (A few of these 2208 but you must take care in writing the function. (A few of these
2209 variables are actually normal hooks which were named before we 2209 variables, notably those ending in @samp{-hooks}, are actually
2210 established the convention of using @samp{-hook} for them.) 2210 normal hooks which were named before we established the convention of
2211 using @samp{-hook} for them.)
2211 2212
2212 If the variable's name ends in @samp{-function}, then its value 2213 If the variable's name ends in @samp{-function}, then its value
2213 is just a single function, not a list of functions. 2214 is just a single function, not a list of functions.
2214 2215
2215 Here's an example that uses a mode hook to turn on Auto Fill mode when 2216 Here's an example that uses a mode hook to turn on Auto Fill mode when
2288 @var{function} goes at the front of the hook list, so it will be 2289 @var{function} goes at the front of the hook list, so it will be
2289 executed first (barring another @code{add-hook} call). If the optional 2290 executed first (barring another @code{add-hook} call). If the optional
2290 argument @var{append} is non-@code{nil}, the new hook function goes at 2291 argument @var{append} is non-@code{nil}, the new hook function goes at
2291 the end of the hook list and will be executed last. 2292 the end of the hook list and will be executed last.
2292 2293
2293 If @var{local} is non-@code{nil}, that says to make the new hook 2294 If @var{local} is non-@code{nil}, that says to add @var{function}
2294 function buffer-local in the current buffer and automatically calls 2295 to the buffer-local hook list instead of to the global hook list.
2295 @code{make-local-hook} to make the hook itself buffer-local.
2296 @end defun 2296 @end defun
2297 2297
2298 @defun remove-hook hook function &optional local 2298 @defun remove-hook hook function &optional local
2299 This function removes @var{function} from the hook variable @var{hook}. 2299 This function removes @var{function} from the hook variable @var{hook}.
2300 2300
2301 If @var{local} is non-@code{nil}, that says to remove @var{function} 2301 If @var{local} is non-@code{nil}, that says to remove @var{function}
2302 from the buffer-local hook list instead of from the global hook list. 2302 from the buffer-local hook list instead of from the global hook list.
2303 If the hook variable itself is not buffer-local, then the value of
2304 @var{local} makes no difference.
2305 @end defun 2303 @end defun
2306
2307 @defun make-local-hook hook
2308 This function makes the hook variable @code{hook} buffer-local in the
2309 current buffer. When a hook variable is buffer-local, it can have
2310 buffer-local and global hook functions, and @code{run-hooks} runs all of
2311 them.
2312
2313 This function works by adding @code{t} as an element of the buffer-local
2314 value. That serves as a flag to use the hook functions listed in the default
2315 value of the hook variable, as well as those listed in the buffer-local value.
2316 Since @code{run-hooks} understands this flag, @code{make-local-hook}
2317 works with all normal hooks. It works for only some non-normal
2318 hooks---those whose callers have been updated to understand this meaning
2319 of @code{t}.
2320
2321 Do not use @code{make-local-variable} directly for hook variables; it is
2322 not sufficient.
2323 @end defun