/[emacs]/emacs/lisp/subr.el
ViewVC logotype

Diff of /emacs/lisp/subr.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.462 by monnier, Mon Jun 13 20:45:50 2005 UTC revision 1.463 by kfstorm, Mon Jun 13 21:29:52 2005 UTC
# Line 957  other hooks, such as major mode hooks, c Line 957  other hooks, such as major mode hooks, c
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    

Legend:
Removed from v.1.462  
changed lines
  Added in v.1.463

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26