From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: should search ring contain duplicates? Date: Thu, 04 May 2006 12:12:20 +0200 Message-ID: References: <200605030727.k437R2Wx009975@amrm2.ics.uci.edu> <87bqufwbls.fsf@jurta.org> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1146737662 2431 80.91.229.2 (4 May 2006 10:14:22 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 4 May 2006 10:14:22 +0000 (UTC) Cc: dann@ics.uci.edu, emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 04 12:14:18 2006 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Fbaqf-0002pW-U5 for ged-emacs-devel@m.gmane.org; Thu, 04 May 2006 12:14:18 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fbaqf-0007n0-9g for ged-emacs-devel@m.gmane.org; Thu, 04 May 2006 06:14:17 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FbaqT-0007mI-Tm for emacs-devel@gnu.org; Thu, 04 May 2006 06:14:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FbaqT-0007lt-49 for emacs-devel@gnu.org; Thu, 04 May 2006 06:14:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FbaqS-0007lo-Vd for emacs-devel@gnu.org; Thu, 04 May 2006 06:14:04 -0400 Original-Received: from [195.41.46.236] (helo=pfepb.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fbar3-0002mZ-4x for emacs-devel@gnu.org; Thu, 04 May 2006 06:14:41 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepb.post.tele.dk (Postfix) with SMTP id 8A97AA5006C; Thu, 4 May 2006 12:14:02 +0200 (CEST) Original-To: Juri Linkov In-Reply-To: (Kim F. Storm's message of "Wed, 03 May 2006 15:53:39 +0200") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:53886 Archived-At: storm@cua.dk (Kim F. Storm) writes: > I definitely think we need the history-push macro! > Here is something which works for me: .. almost :-) Here is a better version: (defmacro 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." (declare (debug (form sexp))) (unless maxelt (setq maxelt `(or (get ',history 'history-length) history-length))) `(let ((len ,maxelt)) (if history-delete-duplicates (setq ,history (delete ,newelt ,history))) (setq ,history (cons ,newelt ,history)) (when (integerp len) (if (= 0 len) (setq ,history nil) (if (> (length ,history) len) (setcdr (nthcdr (1- len) ,history) nil)))))) -- Kim F. Storm http://www.cua.dk