[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: should search ring contain duplicates?
From: |
Stuart D. Herring |
Subject: |
Re: should search ring contain duplicates? |
Date: |
Thu, 4 May 2006 09:05:57 -0700 (PDT) |
User-agent: |
SquirrelMail/1.4.3a-11.EL3 |
> (defun history-push (newelt history &optional maxelt)
> "Add NEWELT to the history list stored in the symbol HISTORY.
> If symbol MAXELT is specified, the maximum length of the history is
> specified by the value of that symbol. Otherwise, the maximum history
> length is to the value of the `history-length' property on symbol
> HISTORY, if set, or to the value of the `history-length' variable.
> Remove duplicates of NEWELT unless `history-delete-duplicates' is nil."
> (unless maxelt
> (setq maxelt (or (get history 'history-length)
> history-length)))
> (if history-delete-duplicates
> (set history (delete newelt (symbol-value history))))
> (set history (cons newelt (symbol-value history)))
> (when (integerp maxelt)
> (if (= 0 maxelt)
> (set history nil)
> (if (> (length (symbol-value history)) maxelt)
> (setcdr (nthcdr (1- maxelt) (symbol-value history)) nil)))))
>
> Sure, you need to quote history in the call then, but it seems like
> the trouble for a macro is not really warranted.
Evaluating the history argument is a feature, not a bug. It lets you do
something like this:
(defun isearch-update-ring (string &optional regexp)
"Add STRING to the beginning of the search ring.
REGEXP says which ring to use."
(history-push string
(if regexp 'regexp-search-ring 'search-ring)
(if regexp regexp-search-ring-max search-ring-max)))
(With, of course, modifications if Kim's `add-to-history' is used instead.)
Davis
--
This product is sold by volume, not by mass. If it appears too dense or
too sparse, it is because mass-energy conversion has occurred during
shipping.
- Re: should search ring contain duplicates?, (continued)
- 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, 2006/05/04
- 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 <=
- 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
- query-replace in isearch (was Re: should search ring contain duplicates?), Dan Nicolaescu, 2006/05/03
- Re: query-replace in isearch, Juri Linkov, 2006/05/03
- Re: query-replace in isearch (was Re: should search ring contain duplicates?), Richard Stallman, 2006/05/03
- Re: query-replace in isearch (was Re: should search ring contain duplicates?), Richard Stallman, 2006/05/10
- Re: query-replace in isearch (was Re: should search ring contain duplicates?), Juri Linkov, 2006/05/11
- Re: query-replace in isearch (was Re: should search ring contain duplicates?), Kim F. Storm, 2006/05/11
- Re: query-replace in isearch (was Re: should search ring contain duplicates?), Juri Linkov, 2006/05/11