[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: should search ring contain duplicates?
From: |
Kim F. Storm |
Subject: |
Re: should search ring contain duplicates? |
Date: |
Thu, 04 May 2006 14:19:59 +0200 |
User-agent: |
Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) |
David Kastrup <address@hidden> writes:
> What is the rationale for making this a macro?
It's named ...-push :-)
> Sure, you need to quote history in the call then, but it seems like
> the trouble for a macro is not really warranted.
You're right, so let's change it to a defun.
But then, to reduce confusion, the name should be `add-to-history',
and the sequence of args changed to match the interface of add-to-list.
(defun add-to-history (history-var newelt &optional maxelt)
"Add NEWELT to the history list stored in the variable HISTORY-VAR.
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."
(unless maxelt
(setq maxelt (or (get history-var 'history-length)
history-length)))
(let ((history (symbol-value history-var)))
(if history-delete-duplicates
(setq history (delete newelt history)))
(setq history (cons newelt history))
(when (integerp maxelt)
(if (= 0 maxelt)
(setq history nil)
(if (> (length history) maxelt)
(setcdr (nthcdr (1- maxelt) history) nil))))
(set history-var history)))
--
Kim F. Storm <address@hidden> http://www.cua.dk
- should search ring contain duplicates?, Drew Adams, 2006/05/02
- Re: should search ring contain duplicates?, Dan Nicolaescu, 2006/05/03
- Re: should search ring contain duplicates?, Kim F. Storm, 2006/05/03
- Re: should search ring contain duplicates?, Juri Linkov, 2006/05/03
- Re: should search ring contain duplicates?, Kim F. Storm, 2006/05/03
- Re: should search ring contain duplicates?, Kim F. Storm, 2006/05/04
- Re: should search ring contain duplicates?, David Kastrup, 2006/05/04
- Re: should search ring contain duplicates?, Stefan Monnier, 2006/05/04
- Re: should search ring contain duplicates?,
Kim F. Storm <=
- Re: should search ring contain duplicates?, David Kastrup, 2006/05/04
- Re: should search ring contain duplicates?, Richard Stallman, 2006/05/05
- Re: should search ring contain duplicates?, Kim F. Storm, 2006/05/05
- Re: should search ring contain duplicates?, Eli Zaretskii, 2006/05/06
- Re: should search ring contain duplicates?, Richard Stallman, 2006/05/06
- Re: should search ring contain duplicates?, Kim F. Storm, 2006/05/07
- Re: should search ring contain duplicates?, Stuart D. Herring, 2006/05/04
- Re: should search ring contain duplicates?, David Kastrup, 2006/05/04
- Re: should search ring contain duplicates?, Stuart D. Herring, 2006/05/04
- Re: should search ring contain duplicates?, Kim F. Storm, 2006/05/04