diff options
| -rw-r--r-- | lisp/subr.el | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index f913e984b88..f0b8f9e96a7 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -960,12 +960,11 @@ other hooks, such as major mode hooks, can do the job." | |||
| 960 | 960 | ||
| 961 | (defun add-to-ordered-list (list-var element &optional order) | 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. | 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'. | 963 | The test for presence of ELEMENT is done with `eq'. |
| 964 | 964 | ||
| 965 | The resulting list is reordered so that the elements are in the | 965 | The resulting list is reordered so that the elements are in the |
| 966 | order given by each element's numeric list order. | 966 | order given by each element's numeric list order. Elements |
| 967 | Elements without a numeric list order are placed at the end of | 967 | without a numeric list order are placed at the end of the list. |
| 968 | the list. | ||
| 969 | 968 | ||
| 970 | If the third optional argument ORDER is non-nil, set the | 969 | If the third optional argument ORDER is non-nil, set the |
| 971 | element's list order to the given value. | 970 | element's list order to the given value. |
| @@ -979,16 +978,16 @@ The return value is the new value of LIST-VAR." | |||
| 979 | (put list-var 'list-order | 978 | (put list-var 'list-order |
| 980 | (setq ordering (make-hash-table :weakness 'key :test 'eq)))) | 979 | (setq ordering (make-hash-table :weakness 'key :test 'eq)))) |
| 981 | (when order | 980 | (when order |
| 982 | (puthash element order ordering)) | 981 | (puthash element (and (numberp order) order) ordering)) |
| 983 | (add-to-list list-var element) | 982 | (unless (memq element (symbol-value list-var)) |
| 983 | (set list-var (cons element (symbol-value list-var)))) | ||
| 984 | (set list-var (sort (symbol-value list-var) | 984 | (set list-var (sort (symbol-value list-var) |
| 985 | (lambda (a b) | 985 | (lambda (a b) |
| 986 | (let ((oa (gethash a ordering)) | 986 | (let ((oa (gethash a ordering)) |
| 987 | (ob (gethash b ordering))) | 987 | (ob (gethash b ordering))) |
| 988 | (cond | 988 | (if (and oa ob) |
| 989 | ((not oa) nil) | 989 | (< oa ob) |
| 990 | ((not ob) t) | 990 | oa))))))) |
| 991 | (t (< oa ob))))))))) | ||
| 992 | 991 | ||
| 993 | 992 | ||
| 994 | ;;; Load history | 993 | ;;; Load history |