diff options
author | Karoly Lorentey <[email protected]> | 2006-05-17 18:05:02 +0000 |
---|---|---|
committer | Karoly Lorentey <[email protected]> | 2006-05-17 18:05:02 +0000 |
commit | 9f97e26d01003a17b861505d535c89ad73799b7e (patch) | |
tree | 5855a1dedaf55418a1e2b867d5813853287cf474 /lisp/subr.el | |
parent | 8dadeb1e1f78c7be07db5ae78aa9eed58d272a4e (diff) | |
parent | 8d1bec8de1c570475c1332d1305bea21ffda44f1 (diff) |
Merged from [email protected]
Patches applied:
* [email protected]/emacs--devo--0--patch-273
Update from CVS
* [email protected]/emacs--devo--0--patch-274
Update from CVS
* [email protected]/emacs--devo--0--patch-275
Update from CVS
* [email protected]/emacs--devo--0--patch-276
Update from CVS
* [email protected]/emacs--devo--0--patch-277
Update from CVS
* [email protected]/emacs--devo--0--patch-278
Update from CVS
* [email protected]/emacs--devo--0--patch-279
Update from CVS
* [email protected]/emacs--devo--0--patch-280
Update etc/MORE.STUFF.
* [email protected]/emacs--devo--0--patch-281
Update from CVS
* [email protected]/emacs--devo--0--patch-282
Update from CVS
* [email protected]/emacs--devo--0--patch-283
Merge from gnus--rel--5.10
* [email protected]/emacs--devo--0--patch-284
Update from CVS
* [email protected]/gnus--rel--5.10--patch-101
Update from CVS
git-archimport-id: [email protected]/emacs--multi-tty--0--patch-557
Diffstat (limited to 'lisp/subr.el')
-rw-r--r-- | lisp/subr.el | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index bc7789f338..2e18efd029 100644 --- a/lisp/subr.el +++ b/lisp/subr.el @@ -1123,28 +1123,36 @@ The return value is the new value of LIST-VAR." (< oa ob) oa))))))) -(defun add-to-history (history-var newelt &optional maxelt) +(defun add-to-history (history-var newelt &optional maxelt keep-all) "Add NEWELT to the history list stored in the variable HISTORY-VAR. Return the new history list. If MAXELT is non-nil, it specifies the maximum length of the history. Otherwise, the maximum history length is the value of the `history-length' property on symbol HISTORY-VAR, if set, or the value of the `history-length' variable. -Remove duplicates of NEWELT unless `history-delete-duplicates' is nil." +Remove duplicates of NEWELT if `history-delete-duplicates' is non-nil. +If optional fourth arg KEEP-ALL is non-nil, add NEWELT to history even +if it is empty or a duplicate." (unless maxelt (setq maxelt (or (get history-var 'history-length) history-length))) (let ((history (symbol-value history-var)) tail) - (if history-delete-duplicates - (setq history (delete newelt history))) - (setq history (cons newelt history)) - (when (integerp maxelt) - (if (= 0 maxelt) - (setq history nil) - (setq tail (nthcdr (1- maxelt) history)) - (when (consp tail) - (setcdr tail nil)))) + (when (and (listp history) + (or keep-all + (not (stringp newelt)) + (> (length newelt) 0)) + (or keep-all + (not (equal (car history) newelt)))) + (if history-delete-duplicates + (delete newelt history)) + (setq history (cons newelt history)) + (when (integerp maxelt) + (if (= 0 maxelt) + (setq history nil) + (setq tail (nthcdr (1- maxelt) history)) + (when (consp tail) + (setcdr tail nil))))) (set history-var history))) |