Mercurial > hg > xemacs-beta
changeset 878:64f38afaab2d
[xemacs-hg @ 2002-06-23 22:03:32 by youngs]
2002-06-22 Ville Skyttä <ville.skytta@xemacs.org>
* subr.el (add-to-list): Sync with GNU Emacs 21.2, adding the
"&optional append" argument.
author | youngs |
---|---|
date | Sun, 23 Jun 2002 22:03:33 +0000 |
parents | e54d47b2d736 |
children | f809bc97829a |
files | lisp/ChangeLog lisp/subr.el |
diffstat | 2 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/lisp/ChangeLog Sun Jun 23 09:54:41 2002 +0000 +++ b/lisp/ChangeLog Sun Jun 23 22:03:33 2002 +0000 @@ -1,3 +1,8 @@ +2002-06-22 Ville Skyttä <ville.skytta@xemacs.org> + + * subr.el (add-to-list): Sync with GNU Emacs 21.2, adding the + "&optional append" argument. + 2002-06-23 Stephen J. Turnbull <stephen@xemacs.org> * unicode.el (load-unicode-tables): Comment loading 8859-1.TXT.
--- a/lisp/subr.el Sun Jun 23 09:54:41 2002 +0000 +++ b/lisp/subr.el Sun Jun 23 22:03:33 2002 +0000 @@ -301,16 +301,24 @@ (make-local-hook hook) (add-one-shot-hook hook function append t)) -(defun add-to-list (list-var element) +(defun add-to-list (list-var element &optional append) "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. The test for presence of ELEMENT is done with `equal'. +If ELEMENT is added, it is added at the beginning of the list, +unless the optional argument APPEND is non-nil, in which case +ELEMENT is added at the end. + 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))))) + (if (member element (symbol-value list-var)) + (symbol-value list-var) + (set list-var + (if append + (append (symbol-value list-var) (list element)) + (cons element (symbol-value list-var)))))) ;; XEmacs additions ;; called by Fkill_buffer()