emacs-devel
[Top][All Lists]
Advanced

[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: Wed, 03 May 2006 15:53:39 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

Juri Linkov <address@hidden> writes:

> Since query-replace is the only place in Emacs that uses this new argument,
> it is better to remove it now before the release, and to use a new
> macro `history-push' in `query-replace-read-to' to treat the query-replace
> history specially.

Agree.

> Below is a tested patch that removes `keep-all' from `read-from-minibuffer',
> adds duplicate replacement strings to the query-replace history explicitly,
> and fixes more places where the value of `history-delete-duplicates'
> is not taken into account yet 

Looks good to me!

>                               (namely, `repeat-complex-command',
> `call-interactively', and `isearch-update-ring').  This patch doesn't use
> a new macro `history-push', but it would be easy to add it later to two
> places in `isearch-update-ring' and `query-replace-read-to'.

I definitely think we need the history-push macro!
Here is something which works for me:


(defmacro history-push (newelt history &optional maxelt)
  "Add NEWELT to the history list stored in the symbol HISTORY.
Truncate the history to max MAXELT elements, if specified, or
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."
  (declare (debug (form sexp)))
  `(let ((len ,maxelt))
     (if history-delete-duplicates
         (setq ,history (delete ,newelt ,history)))
     (setq ,history (cons ,newelt ,history))
     (if (null len)
         (setq len (or (get ',history 'history-length)
                       history-length)))
     (if (integerp len)
         (if (= 0 len)
             (setq ,history nil)
           (if (> (length ,history) len)
               (setcdr (nthcdr (1- len) ,history) nil))))))


-- 
Kim F. Storm <address@hidden> http://www.cua.dk





reply via email to

[Prev in Thread] Current Thread [Next in Thread]