zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: Finer control over what gets written to the history file
Date: Wed, 16 Oct 2013 09:35:04 +0100	[thread overview]
Message-ID: <20131016093504.1761f16e@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <131015222504.ZM3017@torch.brasslantern.com>

On Tue, 15 Oct 2013 22:25:04 -0700
Bart Schaefer <schaefer@brasslantern.com> 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


      reply	other threads:[~2013-10-16  8:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-15 16:41 Bart Schaefer
2013-10-15 16:58 ` Peter Stephenson
2013-10-16  0:34   ` Bart Schaefer
2013-10-16  8:55     ` Peter Stephenson
2013-10-16  9:20       ` Peter Stephenson
2013-10-17 14:20         ` Bart Schaefer
2013-10-17 14:28           ` Peter Stephenson
2013-10-16 10:04       ` Peter Stephenson
2013-10-16  5:25   ` Bart Schaefer
2013-10-16  8:35     ` Peter Stephenson [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131016093504.1761f16e@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).