From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Kevin Rodgers Newsgroups: gmane.emacs.help Subject: Re: length of query-replace-history list Date: Thu, 01 Jun 2006 15:36:48 -0600 Organization: IHS Message-ID: References: <933ba$447dc666$49fa4f5$15189@DIALUPUSA.NET> <4da72$447f07d9$49fa79b$23416@DIALUPUSA.NET> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: sea.gmane.org 1149197910 31199 80.91.229.2 (1 Jun 2006 21:38:30 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 1 Jun 2006 21:38:30 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 01 23:38:28 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Flurz-0005v6-IA for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Jun 2006 23:38:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Flury-0008LB-Gx for geh-help-gnu-emacs@m.gmane.org; Thu, 01 Jun 2006 17:38:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Flurb-0008AR-Iw for help-gnu-emacs@gnu.org; Thu, 01 Jun 2006 17:37:55 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FlurZ-00089L-Jc for help-gnu-emacs@gnu.org; Thu, 01 Jun 2006 17:37:54 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FlurZ-00089G-Bf for help-gnu-emacs@gnu.org; Thu, 01 Jun 2006 17:37:53 -0400 Original-Received: from [80.91.229.2] (helo=ciao.gmane.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA:32) (Exim 4.52) id 1Fluxt-0000CD-G3 for help-gnu-emacs@gnu.org; Thu, 01 Jun 2006 17:44:25 -0400 Original-Received: from list by ciao.gmane.org with local (Exim 4.43) id 1FlurV-0005rI-7a for help-gnu-emacs@gnu.org; Thu, 01 Jun 2006 23:37:50 +0200 Original-Received: from 207.167.42.206 ([207.167.42.206]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 Jun 2006 23:37:49 +0200 Original-Received: from ihs_4664 by 207.167.42.206 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 01 Jun 2006 23:37:49 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-To: help-gnu-emacs@gnu.org Original-Lines: 58 Original-X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 207.167.42.206 User-Agent: Thunderbird 1.5.0.2 (Windows/20060308) In-Reply-To: <4da72$447f07d9$49fa79b$23416@DIALUPUSA.NET> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:35309 Archived-At: B. T. Raven wrote: > Thanks, Kevin. Now that I understand what's going on, it doesn't seem like > it's worth while just to save a few hundred bytes. I had an idea to save > the qrh into a saved association list, something like: > > (setq sal (cons (cons (cadr query-replace-history) (car > query-replace-history)) sal)) You could use desktop-save-mode and add query-replace-history to desktop-globals-to-save. > The idea is to re-load this later and run query replace in batch mode on > other files. I have no idea how to do this in detail but it seems possible > and it would be very useful to me. Maybe instead of setting it to 2, I'll > set it to t, and then then figure out how to manipulate the resulting flat > list of strings after an hours' long session of query-replacing. You could also set desktop-base-file-name to specify a file just for this specific purpose, and save just the last elements of query-replace-history. ,----[ C-h v desktop-save-hook RET ] | desktop-save-hook is a variable defined in `desktop.el'. | Its value is nil | | Documentation: | Normal hook run before the desktop is saved in a desktop file. | This is useful for truncating history lists, for example. | | You can customize this variable. | | [back] `---- (setq desktop-base-file-name ".emacs.batch.desktop" desktop-globals-to-save 'query-replace-history) (add-hook desktop-save-hook (lambda () (when (cdr (cdr query-replace-history)) (setcdr (cdr query-replace-history) nil)))) > Since for my needs this list (sal) of dotted pairs would be a few thousand > elements long, it is probably not the best data structure to use. Could > something along this line be done with a hash table? Do you want all of the history or not? If you only want 2 elements as you originally said, then don't bother saving and manipulating anything else. If you do want the whole history, a list of strings may be as good as anything -- after all, how do you know which search and replace strings to use? Finally, note that you can set query-replace-from-history-variable and query-replace-to-history-variable to different symbols, and save them instead. -- Kevin