From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 18905 invoked from network); 8 May 1999 23:43:41 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 8 May 1999 23:43:41 -0000 Received: (qmail 8105 invoked by alias); 8 May 1999 23:43:34 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6241 Received: (qmail 8098 invoked from network); 8 May 1999 23:43:33 -0000 From: Wayne Davison Message-Id: <199905082343.QAA08737@bebop.clari.net> To: Peter Stephenson Cc: zsh-workers@sunsite.auc.dk In-reply-to: pws's message of Sat, 08 May 1999 16:01:21 +0200. <9905081401.AA40488@ibmth.df.unipi.it> Subject: Re: PATCH: history improvements for 3.1.5-pws-17 and 3.0.6-pre-2 Date: Sat, 08 May 1999 16:43:27 -0700 Sender: wayne@clari.net Peter Stephenson writes: > after I've typed something in one shell, and hit return in another > shell, I expect to be able just to use up-line-or-history to get to > what's in the other shell I'm torn on the issue, because sometimes I want to up-arrow through the total history, and sometimes I just want to press ^P and run the last command that I ran in this window, no exceptions. If you'd like to change the current behavior for the up/down commands, apply this patch: Index: Src/Zle/zle_hist.c @@ -461,7 +461,7 @@ int zle_goto_hist(int ev, int n) { - Histent he = movehistent(quietgethist(ev), n, HIST_FOREIGN); + Histent he = movehistent(quietgethist(ev), n, 0); if (!he) return 0; zle_setline(he); Note that this change doesn't affect ! references, so !! would still run the last command that was run in the current shell. I'd be interested in suggestions for how we can let the user choose between local-history and full-history movement. Perhaps a toggle command? Or a bindable prefix (so I can have ^P ignore shared history, and Up-Arrow include it)? I like this idea. > I'd like to suggest that any zle reference to the history [...] > causes the newly imported stuff to be visible. I think that some zle commands, such as accept_and_infer_next_ history, should remain unaffected by foreign commands. > for some reason due to the internal handling it's not enough to > make what I just typed in shell 1 appear [...] It only happens > after I've typed a new command in shell 2, which can't be a > history command or a blank line I think you've misinterpreted what's going on. The current code waits until the command _finishes_ before adding it to the history file. I did this because the extended_history format contains the finish time of the command. I also don't like this delay in adding the command, though, so I think we add the command after it is typed, and just live with the fact that all the finish times will be the same as the start times when using incremental_append_history (which is used by shared_history). Here's the change to append the history in hend() rather than hbegin(): Index: Src/hist.c @@ -671,8 +671,6 @@ if (hist_ring && !hist_ring->ftim) hist_ring->ftim = time(NULL); if (interact && isset(SHINSTDIN) && !strin) { - if (isset(SHAREHISTORY) || isset(INCREMENTALAPPENDHISTORY)) - savehistfile(NULL, 1, HFILE_USE_OPTIONS | HFILE_FAST); histactive = HA_ACTIVE; attachtty(mypgrp); if (!hist_ring) @@ -962,6 +960,8 @@ zfree(chwords, chwordlen*sizeof(short)); chline = NULL; histactive = 0; + if (isset(SHAREHISTORY) || isset(INCREMENTALAPPENDHISTORY)) + savehistfile(NULL, 1, HFILE_USE_OPTIONS | HFILE_FAST); return !(flag & HISTFLAG_NOEXEC || errflag); } Thanks for the feedback -- I appreciate it! ..wayne..