diff options
-rw-r--r-- | lisp/subr.el | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index 7c0ae0cb91..b623658e8d 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -712,7 +712,12 @@ To make a hook variable buffer-local, always use (set-default hook hook-value))))) (defun add-to-list (list-var element) - "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet." + "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. +If you want to use `add-to-list' on a variable that is not defined +until a certain package is loaded, you should put the call to `add-to-list' +into a hook function that will be run only after loading the package. +`eval-after-load' provides one way to do this. In some cases +other hooks, such as major mode hooks, can do the job." (or (member element (symbol-value list-var)) (set list-var (cons element (symbol-value list-var))))) |