aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/subr.el11
1 files changed, 8 insertions, 3 deletions
diff --git a/lisp/subr.el b/lisp/subr.el
index ebf35337bb3..ca75c9f97a3 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -761,10 +761,12 @@ To make a hook variable buffer-local, always use
761 ;; Set the actual variable 761 ;; Set the actual variable
762 (if local (set hook hook-value) (set-default hook hook-value)))) 762 (if local (set hook hook-value) (set-default hook hook-value))))
763 763
764(defun add-to-list (list-var element) 764(defun add-to-list (list-var element &optional append)
765 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. 765 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet.
766The test for presence of ELEMENT is done with `equal'. 766The test for presence of ELEMENT is done with `equal'.
767If ELEMENT is added, it is added at the beginning of the list. 767If ELEMENT is added, it is added at the beginning of the list,
768unless the optional argument APPEND is non-nil, in which case
769ELEMENT is added at the end.
768 770
769If you want to use `add-to-list' on a variable that is not defined 771If you want to use `add-to-list' on a variable that is not defined
770until a certain package is loaded, you should put the call to `add-to-list' 772until a certain package is loaded, you should put the call to `add-to-list'
@@ -773,7 +775,10 @@ into a hook function that will be run only after loading the package.
773other hooks, such as major mode hooks, can do the job." 775other hooks, such as major mode hooks, can do the job."
774 (if (member element (symbol-value list-var)) 776 (if (member element (symbol-value list-var))
775 (symbol-value list-var) 777 (symbol-value list-var)
776 (set list-var (cons element (symbol-value list-var))))) 778 (set list-var
779 (if append
780 (append (symbol-value list-var) (list element))
781 (cons element (symbol-value list-var))))))
777 782
778;;;; Specifying things to do after certain files are loaded. 783;;;; Specifying things to do after certain files are loaded.
779 784