From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dan Nicolaescu Newsgroups: gmane.emacs.devel Subject: Re: should search ring contain duplicates? Date: Wed, 3 May 2006 00:27:02 -0700 Message-ID: <200605030727.k437R2Wx009975@amrm2.ics.uci.edu> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1146641261 18826 80.91.229.2 (3 May 2006 07:27:41 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 3 May 2006 07:27:41 +0000 (UTC) Cc: Emacs-Devel Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed May 03 09:27:37 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 1FbBlg-0001Ju-PH for ged-emacs-devel@m.gmane.org; Wed, 03 May 2006 09:27:29 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FbBlf-0001v9-TX for ged-emacs-devel@m.gmane.org; Wed, 03 May 2006 03:27:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FbBlJ-0001s0-Qg for emacs-devel@gnu.org; Wed, 03 May 2006 03:27:05 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FbBlJ-0001qp-3m for emacs-devel@gnu.org; Wed, 03 May 2006 03:27:05 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FbBlI-0001qL-Qb for emacs-devel@gnu.org; Wed, 03 May 2006 03:27:04 -0400 Original-Received: from [128.195.11.178] (helo=amrm2.ics.uci.edu) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1FbBld-0004Sq-8A for emacs-devel@gnu.org; Wed, 03 May 2006 03:27:25 -0400 Original-Received: from amrm2.ics.uci.edu (amrm2.ics.uci.edu [127.0.0.1]) by amrm2.ics.uci.edu (8.13.6/8.13.6) with ESMTP id k437R39G009976; Wed, 3 May 2006 00:27:03 -0700 Original-Received: (from dann@localhost) by amrm2.ics.uci.edu (8.13.6/8.13.6/Submit) id k437R2Wx009975; Wed, 3 May 2006 00:27:02 -0700 Original-To: "Drew Adams" In-Reply-To: (Drew Adams's message of "Tue, 2 May 2006 17:54:36 -0700") Original-Lines: 40 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:53835 Archived-At: "Drew Adams" writes: > Each successful incremental search adds the search string to the search ring > (as the most recent entry), even if it is already in the ring past the first > entry. Nothing prevents the ring from containing multiple copies of the same > string, which seems wasteful (and useless). At the limit, the search ring, > regardless of its length, might contain as few as two different search > strings. > > Shouldn't `isearch-update-ring' (in isearch.el) add the latest search string > at the front of the ring but remove it elsewhere in the ring? The result > would be a more useful ring. `isearch-update-ring' could at least do that when history-delete-duplicates is t. Something like this could help: [completely untested] (defun isearch-update-ring (string &optional regexp) "Add STRING to the beginning of the search ring. REGEXP says which ring to use." (if regexp (if (or (null regexp-search-ring) (not (string= string (car regexp-search-ring)))) (progn (when history-delete-duplicates (setq regexp-search-ring (delete string regexp-search-ring))) (push string regexp-search-ring) (if (> (length regexp-search-ring) regexp-search-ring-max) (setcdr (nthcdr (1- search-ring-max) regexp-search-ring) nil)))) (if (or (null search-ring) (not (string= string (car search-ring)))) (progn (when history-delete-duplicates (setq search-ring (delete string search-ring))) (push string search-ring) (if (> (length search-ring) search-ring-max) (setcdr (nthcdr (1- search-ring-max) search-ring) nil))))))