957 |
(append (symbol-value list-var) (list element)) |
(append (symbol-value list-var) (list element)) |
958 |
(cons element (symbol-value list-var)))))) |
(cons element (symbol-value list-var)))))) |
959 |
|
|
960 |
|
|
961 |
|
(defun add-to-ordered-list (list-var element &optional order) |
962 |
|
"Add to the value of LIST-VAR the element ELEMENT if it isn't there yet. |
963 |
|
The test for presence of ELEMENT is done with `equal'. |
964 |
|
|
965 |
|
The resulting list is reordered so that the elements are in the |
966 |
|
order given by each element's `list-order' property (a number). |
967 |
|
Elements which are not symbols, and symbol elements without a |
968 |
|
numeric `lisp-order' property are placed at the end of the list. |
969 |
|
|
970 |
|
If the third optional argument ORDER is non-nil and ELEMENT is |
971 |
|
a symbol, set the symbol's `list-order' property to the given value. |
972 |
|
|
973 |
|
The return value is the new value of LIST-VAR." |
974 |
|
(when (and order (symbolp element)) |
975 |
|
(put element 'list-order (and (numberp order) order))) |
976 |
|
(add-to-list list-var element) |
977 |
|
(set list-var (sort (symbol-value list-var) |
978 |
|
(lambda (a b) |
979 |
|
(let ((oa (and (symbolp a) (get a 'list-order))) |
980 |
|
(ob (and (symbolp b) (get b 'list-order)))) |
981 |
|
(cond |
982 |
|
((not oa) nil) |
983 |
|
((not ob) t) |
984 |
|
(t (< oa ob)))))))) |
985 |
|
|
986 |
|
|
987 |
;;; Load history |
;;; Load history |
988 |
|
|