> A general solution is non-trivial, as there is a potential risk of memory > leaks, as associating ordering information with arbitrary lisp objects > means that we must store a pointer to such objects somewhere, and thus > may leave references to otherwise unused data.
How 'bout the patch below? Look 'ma, no leak! Stefan --- subr.el 14 jun 2005 13:16:55 -0400 1.464 +++ subr.el 14 jun 2005 13:23:20 -0400 @@ -974,25 +974,21 @@ `list-order' property. The return value is the new value of LIST-VAR." - (let* ((ordering (get list-var 'list-order)) - (cur (and (symbolp element) (assq element ordering)))) + (let ((ordering (get list-var 'list-order))) + (unless ordering + (put list-var 'list-order + (setq ordering (make-hash-table :weakness 'key :test 'eq)))) (when order - (unless (symbolp element) - (error "cannot specify order for non-symbols")) - (if cur - (setcdr cur order) - (setq cur (cons element order)) - (setq ordering (cons cur ordering)) - (put list-var 'list-order ordering))) + (puthash element order ordering)) (add-to-list list-var element) (set list-var (sort (symbol-value list-var) (lambda (a b) - (let ((oa (and (symbolp a) (assq a ordering))) - (ob (and (symbolp b) (assq b ordering)))) + (let ((oa (gethash a ordering)) + (ob (gethash b ordering))) (cond ((not oa) nil) ((not ob) t) - (t (< (cdr oa) (cdr ob)))))))))) + (t (< oa ob))))))))) ;;; Load history _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel