From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21150 invoked from network); 19 Nov 2001 16:48:42 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 19 Nov 2001 16:48:42 -0000 Received: (qmail 29369 invoked by alias); 19 Nov 2001 16:48:33 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16266 Received: (qmail 29352 invoked from network); 19 Nov 2001 16:48:31 -0000 From: Bart Schaefer Message-Id: <1011119164824.ZM27974@candle.brasslantern.com> Date: Mon, 19 Nov 2001 16:48:24 +0000 In-Reply-To: <1489.1005931641@csr.com> Comments: In reply to Peter Stephenson "Local history" (Nov 16, 5:27pm) References: <1489.1005931641@csr.com> <20011116100106.A944@lorien.emufarm.org> <7D865FB0D0A1D5118B6E000347055BBB148489@G9JNT.mgb01.telekom.de> In-Reply-To: <20011116100106.A944@lorien.emufarm.org> Comments: In reply to Danek Duvall "Re: Local history" (Nov 16, 10:01am) In-Reply-To: <7D865FB0D0A1D5118B6E000347055BBB148489@G9JNT.mgb01.telekom.de> Comments: In reply to "Wischnowsky, Sven" "Re: Local history" (Nov 19, 9:40am) X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Re: Local history MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Nov 16, 5:27pm, Peter Stephenson wrote: } } I'm still thinking about a way of getting a local command history. My } particular use is so that zcalc and similar functions can keep their own } data, separate from the main command history. It would be nice if the vared builtin could do the same, though that has some problems: `vared -h' would have to switch from the vared history to the command history, and probably also disable saving the vared history. } The first thing I tried was manipulating HISTFILE inside the function and } using fc -R and fc -W. But this doesn't work too well because the history } list at the start contains lots of irrelevant bits. Maybe there's a way of } truncating the internal list after saving one list and before loading the } other, but at this point I start to wonder whether I should be doing } something different. In particular, incremental appending and history } sharing will make things well confused. As Sven mentioned, I've done this before. The basic trick is that HISTSIZE truncates the history as soon as you assign to it, so the technique goes like this: local temphist=${TMPPREFIX}hist SAVEHIST=$HISTSIZE HISTFILE=$temphist fc -W # Save internal history local HISTSIZE=0 # Truncate internal history HISTSIZE=$SAVEHIST HISTFILE=~/.zcalc-history fc -R # Read previous zcalc history # do zcalc stuff ... fc -W # Save zcalc history HISTFILE=$temphist fc -R # Reload old history Then you have to put in the appropriate traps so the old history gets put back even if the function is interrupted, etc. On Nov 16, 10:01am, Danek Duvall wrote: } } Is this related to the problem I'm having with the following function: No, it's not really related. } My normal course is to delete the last few lines of the history. And } while they disappear from the end of the history, they reappear at the } beginning. Re-running the function -- where those lines don't appear in } the editor at all -- makes them disappear entirely. You've probably set the HIST_EXPIRE_DUPS_FIRST option. When the file is read back in, everything in it is a duplicate. So all the existing lines get expired, except the deleted ones, with the effect that what you wanted deleted instead gets moved to the top. Try adding `setopt localoptions no_histexpiredupsfirst' to the function and see whether that doesn't get back the behavior you wanted. On Nov 19, 9:40am, Wischnowsky, Sven wrote: } } I was thinking about doing it only at the very core, namely supporting } more than one history list and a way (option to fc or something) to } switch between these lists. One could then give them names and use } $HISTFILE as the prefix of the filenames for the different histories } (or support per-list flags saying if they are to be saved at all). This is, approximately, what savehistfile() does at the very end. Look for the variable names starting with `remember_'. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net