zsh-users
 help / color / mirror / code / Atom feed
From: Jan Larres <jan@majutsushi.net>
To: zsh-users@zsh.org
Subject: Re: Local/global history with pattern isearch
Date: Fri, 07 Mar 2014 19:49:07 +1300	[thread overview]
Message-ID: <lfbq4m$duv$1@ger.gmane.org> (raw)
In-Reply-To: <140305205344.ZM5782@torch.brasslantern.com>

On 06/03/14 17:53, Bart Schaefer wrote:
> On Mar 4, 12:44pm, Jan Larres wrote:
> }
> } Okay, the good news first: I found the culprit! The issue was caused by
> } the zsh-syntax-highlighting script
>
> Hmm.  I don't use that, but looking at it, it should be the case that if
> you define your widget first then it will skip trying to redefine it,
> and if you define yours second then yours will replace the highlighting
> one.  (This is all because your widget has the same name as a builtin.)
>
> That explains why
> } ... a quick swapping of order doesn't seem to make any
> } difference.

This got me wondering why it wasn't working even though the search
widget got left alone, and so I went trying to figure out which widget
*was* the issue. And, possibly to no-one's surprise, that widget turned
out to be set-local-history. If I redefine that widget so it won't get
redefined again by zsh-syntax-highlighting then the local/global history
functionality works perfectly together with pattern-search. Apparently
the calling of an additional function after that widget confuses it
somehow.

So for those playing along at home this is what I currently have in my
.zshrc:


set-local-history() { zle .set-local-history }
zle -N set-local-history
zle-line-init()  { NUMERIC=1 zle set-local-history }
zle -N zle-line-init
zle-isearch-update() { NUMERIC=0 zle set-local-history }
zle -N zle-isearch-update
zle-isearch-exit()  { NUMERIC=1 zle set-local-history }
zle -N zle-isearch-exit

history-incremental-pattern-search-backward() {
    NUMERIC=0 zle set-local-history
    zle .history-incremental-pattern-search-backward "$@"
}
zle -N history-incremental-pattern-search-backward
bindkey '^r' history-incremental-pattern-search-backward
history-incremental-pattern-search-forward() {
    NUMERIC=0 zle set-local-history
    zle .history-incremental-pattern-search-forward "$@"
}
zle -N history-incremental-pattern-search-forward
bindkey '^s' history-incremental-pattern-search-forward


Thanks for the help, Bart!

-Jan


  reply	other threads:[~2014-03-07  7:07 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
2014-03-03 23:44   ` Jan Larres
2014-03-06  4:53     ` Bart Schaefer
2014-03-07  6:49       ` Jan Larres [this message]
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='lfbq4m$duv$1@ger.gmane.org' \
    --to=jan@majutsushi.net \
    --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).