From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17377 invoked from network); 16 Nov 2001 17:28:01 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 16 Nov 2001 17:28:01 -0000 Received: (qmail 22748 invoked by alias); 16 Nov 2001 17:27:51 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 16260 Received: (qmail 22737 invoked from network); 16 Nov 2001 17:27:50 -0000 To: zsh-workers@sunsite.dk (Zsh hackers list) Subject: Local history Date: Fri, 16 Nov 2001 17:27:21 +0000 Message-ID: <1489.1005931641@csr.com> From: Peter Stephenson 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. 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. Does anyone have any experience of or feeling for this? I can see various possible ways of proceeding, most (given my experience so far) involving internal alterations. However, the fourth possibility is quite attractive. - Tidy up the mechanism in hist.c to make it easier to swap histories. Needs some way of doing this for both the internal history and external files, since Wayne has gone to some lengths to make them consistent. This sounds quite nasty to me. - Abstract the interface in hist.c. Make it support both the current file-based mechanism for accessing the history and a mechanism tied to arrays. The alternative mechanism can be simpler, since the functions that use it can do reading, writing or appending where necessary. - Add an additional array-based system inside zle, so that we don't use hist.c at all in this case. There are two parts to this: adapt zle_history.c for the alternative system, and adapt bin_vared() to put the text into this history. (`Array-based' could mean two things: we input values as an array and export them to an array on entry or exit to the function, or to vared itself, or we tie the entries in the array directly to the history list seen inside zle.) - Write a completely separate history mechanism based on zle widgets. Rebind the keys when using vared. Hence `vared-up-line-or-history' would temporarily replace `up-line-or-history' and look in the array for the previous entry. If zle turns out not to be up to it, we can probably add the necessary functions; they may be of more general use than just history. We can supply this system in Functions/Zle. Unfortunately we have to rewrite the various search functions from scratch, too. - Or maybe I'm being faint-hearted and mainpulating the history parameters and fc will do the trick after all. -- Peter Stephenson Software Engineer CSR Ltd., Science Park, Milton Road, Cambridge, CB4 0WH, UK Tel: +44 (0)1223 392070 ********************************************************************** The information transmitted is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. If you received this in error, please contact the sender and delete the material from any computer. **********************************************************************