Mercurial > hg > xemacs-beta
comparison lisp/subr.el @ 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 | 79c6ff3eef26 |
children | 1e9272790fe0 |
comparison
equal
deleted
inserted
replaced
877:e54d47b2d736 | 878:64f38afaab2d |
---|---|
299 | 299 |
300 See also `add-hook', `add-local-hook', and `add-local-one-shot-hook'." | 300 See also `add-hook', `add-local-hook', and `add-local-one-shot-hook'." |
301 (make-local-hook hook) | 301 (make-local-hook hook) |
302 (add-one-shot-hook hook function append t)) | 302 (add-one-shot-hook hook function append t)) |
303 | 303 |
304 (defun add-to-list (list-var element) | 304 (defun add-to-list (list-var element &optional append) |
305 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. | 305 "Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. |
306 The test for presence of ELEMENT is done with `equal'. | 306 The test for presence of ELEMENT is done with `equal'. |
307 If ELEMENT is added, it is added at the beginning of the list, | |
308 unless the optional argument APPEND is non-nil, in which case | |
309 ELEMENT is added at the end. | |
310 | |
307 If you want to use `add-to-list' on a variable that is not defined | 311 If you want to use `add-to-list' on a variable that is not defined |
308 until a certain package is loaded, you should put the call to `add-to-list' | 312 until a certain package is loaded, you should put the call to `add-to-list' |
309 into a hook function that will be run only after loading the package. | 313 into a hook function that will be run only after loading the package. |
310 `eval-after-load' provides one way to do this. In some cases | 314 `eval-after-load' provides one way to do this. In some cases |
311 other hooks, such as major mode hooks, can do the job." | 315 other hooks, such as major mode hooks, can do the job." |
312 (or (member element (symbol-value list-var)) | 316 (if (member element (symbol-value list-var)) |
313 (set list-var (cons element (symbol-value list-var))))) | 317 (symbol-value list-var) |
318 (set list-var | |
319 (if append | |
320 (append (symbol-value list-var) (list element)) | |
321 (cons element (symbol-value list-var)))))) | |
314 | 322 |
315 ;; XEmacs additions | 323 ;; XEmacs additions |
316 ;; called by Fkill_buffer() | 324 ;; called by Fkill_buffer() |
317 (defvar kill-buffer-hook nil | 325 (defvar kill-buffer-hook nil |
318 "Function or functions to be called when a buffer is killed. | 326 "Function or functions to be called when a buffer is killed. |