From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13693 invoked by alias); 16 Oct 2013 08:35:16 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 31827 Received: (qmail 20792 invoked from network); 16 Oct 2013 08:35:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_PASS autolearn=ham version=3.3.2 X-AuditID: cbfec7f4-b7f0a6d000007b1b-f3-525e4fb98fc4 Date: Wed, 16 Oct 2013 09:35:04 +0100 From: Peter Stephenson To: zsh-workers@zsh.org Subject: Re: Finer control over what gets written to the history file Message-id: <20131016093504.1761f16e@pwslap01u.europe.root.pri> In-reply-to: <131015222504.ZM3017@torch.brasslantern.com> References: <131015094100.ZM2399@torch.brasslantern.com> <20131015175838.19f0256d@pwslap01u.europe.root.pri> <131015222504.ZM3017@torch.brasslantern.com> Organization: Samsung Cambridge Solution Centre X-Mailer: Claws Mail 3.7.9 (GTK+ 2.22.0; i386-redhat-linux-gnu) MIME-version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFupmluLIzCtJLcpLzFFi42I5/e/4Zd2d/nFBBm8f6VkcbH7I5MDoserg B6YAxigum5TUnMyy1CJ9uwSujIlL+Auu8FfMW/yLpYHxJ3cXIyeHhICJRPfLs2wQtpjEhXvr gWwuDiGBpYwSc9avYYZwljNJHF14hBWkikVAVeLN9/9gHWwChhJTN81mBLFFBMQlzq49zwJi Cwu4SpybOQ0ozsHBK2AvcX1rJkiYU8BS4vijD2AlQgJzGSVW9yaB2PwC+hJX/35igjjCXmLm lTNgI3kFBCV+TL4HVs8soCWxeVsTK4QtL7F5zVvmCYwCs5CUzUJSNgtJ2QJG5lWMoqmlyQXF Sem5hnrFibnFpXnpesn5uZsYIQH4ZQfj4mNWhxgFOBiVeHhPRMUGCbEmlhVX5h5ilOBgVhLh TXKPCxLiTUmsrEotyo8vKs1JLT7EyMTBKdXAuKn6zsvIwHWB8Q8ntmx/o7/sV1PE7iPdtfbV kyaG9Bt21z1/mZ60VnaZ8tr+6Xe1yh/zxxb7JTyfYDTphfun6H/PRSSftM2ZMY/jcc1eg1vs /+1U1N+XX6o4xGr48lZxBrfaSrNpt75vO2OzJGpK87p9G+cnhH7mT0lI5dqZsGkyW4XkLdvV HEosxRmJhlrMRcWJAEk+J6YeAgAA On Tue, 15 Oct 2013 22:25:04 -0700 Bart Schaefer wrote: > Incidentally ... > > On Oct 15, 5:58pm, Peter Stephenson quoted the docs: > > > > zshaddhistory > > The following example function first adds the history line to > > the normal history with the newline stripped, which is usually > > the correct behaviour. Then it switches the history context so > > that the line will be written to a history file in the current > > directory. > > > > zshaddhistory() { > > print -sr -- ${1%%$'\n'} > > fc -p .zsh_local_history > > } > > This doesn't quite work, does it? The missing bit being that you also > must have INC_APPEND_HISTORY set, otherwise the stack is popped before > anything is written. Yes, that needs adding. diff --git a/Doc/Zsh/func.yo b/Doc/Zsh/func.yo index 78bdfc0..1f58df8 100644 --- a/Doc/Zsh/func.yo +++ b/Doc/Zsh/func.yo @@ -274,10 +274,13 @@ that in the global tt(HISTFILE) parameter. This is handled specially: the history context is automatically restored after the processing of the history line is finished. -The following example function first adds the history line to the normal -history with the newline stripped, which is usually the correct behaviour. -Then it switches the history context so that the line will -be written to a history file in the current directory. +The following example function works with one of the options +tt(INC_APPEND_HISTORY) or tt(SHARE_HISTORY) set, in order that the line +is written out immediately after the history entry is added. It first +adds the history line to the normal history with the newline stripped, +which is usually the correct behaviour. Then it switches the history +context so that the line will be written to a history file in the +current directory. example(zshaddhistory+LPAR()RPAR() { print -sr -- ${1%%$'\n'} pws