Mercurial > hg > xemacs-beta
comparison lisp/subr.el @ 4462:34b42224a066
Make the #'add-to-list implementation a little conciser and clearer for XEmacs
2008-05-14 Aidan Kehoe <kehoea@parhasard.net>
* subr.el (add-to-list): Implement the same logic with a more
concise syntax; thank you Stephen, in
http://mid.gmane.org/87ablomdwx.fsf@uwakimon.sk.tsukuba.ac.jp .
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 14 May 2008 23:55:13 +0200 |
parents | 42fad34efb3f |
children | 5c651a4e8ed3 |
comparison
equal
deleted
inserted
replaced
4461:42fad34efb3f | 4462:34b42224a066 |
---|---|
400 If you want to use `add-to-list' on a variable that is not defined | 400 If you want to use `add-to-list' on a variable that is not defined |
401 until a certain package is loaded, you should put the call to `add-to-list' | 401 until a certain package is loaded, you should put the call to `add-to-list' |
402 into a hook function that will be run only after loading the package. | 402 into a hook function that will be run only after loading the package. |
403 `eval-after-load' provides one way to do this. In some cases | 403 `eval-after-load' provides one way to do this. In some cases |
404 other hooks, such as major mode hooks, can do the job." | 404 other hooks, such as major mode hooks, can do the job." |
405 (if (if (not compare-fn) | 405 (if (member* (member* element (symbol-value list-var) |
406 (member element (symbol-value list-var)) | 406 :test (or compare-fn #'equal))) |
407 (member* element (symbol-value list-var) :test compare-fn)) | |
408 (symbol-value list-var) | 407 (symbol-value list-var) |
409 (set list-var | 408 (set list-var |
410 (if append | 409 (if append |
411 (append (symbol-value list-var) (list element)) | 410 (append (symbol-value list-var) (list element)) |
412 (cons element (symbol-value list-var)))))) | 411 (cons element (symbol-value list-var)))))) |