From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: should search ring contain duplicates? Date: Thu, 04 May 2006 18:23:47 +0200 Message-ID: <85slnpu5bg.fsf@lola.goethe.zz> References: <200605030727.k437R2Wx009975@amrm2.ics.uci.edu> <87bqufwbls.fsf@jurta.org> <85iromw09n.fsf@lola.goethe.zz> <36938.128.165.123.132.1146758757.squirrel@webmail.lanl.gov> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1146759880 18308 80.91.229.2 (4 May 2006 16:24:40 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 4 May 2006 16:24:40 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu May 04 18:24:39 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 1Fbgcn-0000uk-HD for ged-emacs-devel@m.gmane.org; Thu, 04 May 2006 18:24:21 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Fbgcn-0006ur-0a for ged-emacs-devel@m.gmane.org; Thu, 04 May 2006 12:24:21 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FbgcY-0006tx-72 for emacs-devel@gnu.org; Thu, 04 May 2006 12:24:06 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FbgcX-0006sx-L3 for emacs-devel@gnu.org; Thu, 04 May 2006 12:24:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FbgcX-0006si-EH for emacs-devel@gnu.org; Thu, 04 May 2006 12:24:05 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FbgdA-00030j-Ad for emacs-devel@gnu.org; Thu, 04 May 2006 12:24:44 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1FbgcV-0006lR-QH; Thu, 04 May 2006 12:24:04 -0400 Original-Received: by lola.goethe.zz (Postfix, from userid 1002) id 602961C3ACCD; Thu, 4 May 2006 18:23:47 +0200 (CEST) Original-To: herring@lanl.gov In-Reply-To: <36938.128.165.123.132.1146758757.squirrel@webmail.lanl.gov> (Stuart D. Herring's message of "Thu, 4 May 2006 09:05:57 -0700 (PDT)") 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:53916 Archived-At: "Stuart D. Herring" writes: >> (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))) No, it doesn't. Thanks for making my point that "the trouble for a macro is not really warranted". (get '(if regexp 'regexp-search-ring 'search-ring) 'history-length) is going to throw an error at execution time. Are you sure you know what a macro does? It compiles the form resulting from executing the macro on the quoted arguments at compile time. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum