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 14:19:59 +0200 Message-ID: References: <200605030727.k437R2Wx009975@amrm2.ics.uci.edu> <87bqufwbls.fsf@jurta.org> <85iromw09n.fsf@lola.goethe.zz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1146745335 27612 80.91.229.2 (4 May 2006 12:22:15 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 4 May 2006 12:22:15 +0000 (UTC) Cc: Juri Linkov , 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 14:22:13 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 1FbcqI-00012P-RS for ged-emacs-devel@m.gmane.org; Thu, 04 May 2006 14:22:03 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FbcqI-0003tq-9q for ged-emacs-devel@m.gmane.org; Thu, 04 May 2006 08:22:02 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Fbcq4-0003se-9H for emacs-devel@gnu.org; Thu, 04 May 2006 08:21:48 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Fbcq3-0003sS-FR for emacs-devel@gnu.org; Thu, 04 May 2006 08:21:47 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fbcq3-0003sO-Bz for emacs-devel@gnu.org; Thu, 04 May 2006 08:21:47 -0400 Original-Received: from [195.41.46.235] (helo=pfepa.post.tele.dk) by monty-python.gnu.org with esmtp (Exim 4.52) id 1Fbcqd-0005iY-31; Thu, 04 May 2006 08:22:23 -0400 Original-Received: from kfs-l.imdomain.dk.cua.dk (0x503e2644.bynxx3.adsl-dhcp.tele.dk [80.62.38.68]) by pfepa.post.tele.dk (Postfix) with SMTP id 7C011FAC024; Thu, 4 May 2006 14:21:43 +0200 (CEST) Original-To: David Kastrup In-Reply-To: <85iromw09n.fsf@lola.goethe.zz> (David Kastrup's message of "Thu, 04 May 2006 12:29:56 +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:53896 Archived-At: David Kastrup 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 http://www.cua.dk