zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: Local/global history with pattern isearch
Date: Sun, 02 Mar 2014 21:44:00 -0800	[thread overview]
Message-ID: <140302214400.ZM1868@torch.brasslantern.com> (raw)
In-Reply-To: <lf0vss$4ri$1@ger.gmane.org>

On Mar 3,  5:19pm, Jan Larres wrote:
} Subject: Local/global history with pattern isearch
}
} zle -N history-incremental-pattern-search-backward
} bindkey '^r' history-incremental-pattern-search-backward
} 
} Unfortunately this still isn't quite working for me. It does use the
} shared history when starting the search, but when pressing ^r again it
} fails to find any other results, neither in the shared nor in the local
} history.

This *seems* to be working for me in zsh-5.0.5-71-g965d730 (the latest
pull from git as of my writing this).  I find multiple results with
repeated presses of ^R, and adding   zle -M "$ZLE_STATE"   to the
zle-isearch-update function shows "globalhistory insert" as expected.

I also tried removing   zle set-local-history   from zle-isearch-update
and found that $ZLE_STATE still reports "globalhistory", so the update
hook may not be needed.

} The custom function also doesn't get called again in that case,
} I don't know if that's normal behaviour or not.

As I think was mentioned in the thread when this first came around, the
isearch routines don't use true keymaps; they use the widget names of
regular keymaps but substitute their own widget actions.  This is why
the custom name must be "history-incremental-pattern-search-backward"
in order for this to work at all.  So yes, this is expected.

(Actually you could probably get away with naming it something else as
long as you explicitly bound the search-again key in the isearch keymap
to history-incremental-pattern-search-backward.)

HOWEVER, I think this may be the source of the bug.  Repeating the
search does not exit from the isearch keymap, so zle-isearch-exit is
always called between any two calls of the custom widget.  Thus the
[[ $LASTWIDGET != history-incremental-pattern-search-backward ]]  test
is probably incorrect part of the time.

Try changing to

    history-incremental-pattern-search-backward() {
	NUMERIC=0 zle set-local-history
	zle .history-incremental-pattern-search-backward "$@"
    }

and see if that clears it up?


  reply	other threads:[~2014-03-03  5:44 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-03  4:19 Jan Larres
2014-03-03  5:44 ` Bart Schaefer [this message]
2014-03-03 23:44   ` Jan Larres
2014-03-06  4:53     ` Bart Schaefer
2014-03-07  6:49       ` Jan Larres
2014-03-07  7:51         ` Bart Schaefer
2014-03-11  4:54           ` Jan Larres

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=140302214400.ZM1868@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).