From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16329 invoked by alias); 21 Jul 2015 07:59:03 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 20328 Received: (qmail 11109 invoked from network); 21 Jul 2015 07:59:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2 autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=XZLTo4wPEi/OzVYgeDl7R8TBn75CVENToKJ7Krj8v+k=; b=bTbfRqmZvut/57FLoy11vahVTvuLL0VllVGGUo+mVBaf25V8rXsRB2aQ0W3/ENimjk /J8WhQSYLpZgrpHkqKhUPQ2VnTCBYF81fpzB9QCkHNMKlCE+9CocVaSpVJb9FvW3UMPR AL2myULRYMcxul39kY3OK4xxdR8r9s/vcVh+xK68CuDpcKjNGs4uCMc+hTra3fks+Q29 S6Rt9Ta2NgNm0K1dd4h5Rb4U5uu6daPfqjcY6I1B5P4iX7OnhAecKqYHrGi9Zv/oJRo4 Q9Fy7bJ4KglbtAbG4wuCXl2ZLqDlWyYebiS7W2MS/NdyqOpOammuBskc9/FOPIdvKpjX jhUQ== X-Received: by 10.50.25.167 with SMTP id d7mr21571648igg.59.1437465535361; Tue, 21 Jul 2015 00:58:55 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <150720101425.ZM14010@torch.brasslantern.com> References: <150720101425.ZM14010@torch.brasslantern.com> From: Evgeny Pakhomov Date: Tue, 21 Jul 2015 13:58:36 +0600 Message-ID: Subject: Re: Buffer stack in Vi mode To: Bart Schaefer Cc: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=047d7bdc0fd69cb9f7051b5e0627 --047d7bdc0fd69cb9f7051b5e0627 Content-Type: text/plain; charset=UTF-8 Hi Bart, Thanks for the answer, the widget approach works great! Just as a remark - hh knows about zsh and different history options. There are no problems with EXTENDED_HISTORY on my setup. Regards, Eugene On Mon, Jul 20, 2015 at 11:14 PM, Bart Schaefer wrote: > On Jul 20, 8:45pm, Evgeny Pakhomov wrote: > } > } Excuse me if it's not the correct place to ask - I couldn't find any > better. > } > } I'm trying to use a custom incremental history search command ( > } https://github.com/dvorka/hstr). It works great with "C-r" in the normal > } mode, but in the Vi mode I can't use it in the same way - I can't find > any > } documentation on how to use buffer stack to save already entered command > in > } the Vi mode. > > Some remarks: > > This is using an external program to read the history file, which means > it's probably going to break horribly for a lot of zsh configurations. > The EXTENDED_HISTORY option will probably kill it, which means that the > INC_APPEND_HISTORY_TIME and SHARE_HISTORY options will also break it. > Also if you DO NOT set INC_APPEND_HISTORY, you'll only be able to look > at the history from before the last time a shell exited. > > The recommended way to configure this for zsh: > > bindkey -s "\C-r" "\eqhh\n" > > is using the default binding "\eq" for the push-line widget, which means > this also probably works not-so-well at the PS2 prompt (in a multi-line > construct like a "for" loop). But I guess no worse that it would work > for bash in the same circumstances. > > I'm not going to attempt to learn what else that external program does; > there are a lot of ways to search history in zsh already. > > Anyway, the direct answer to your question is that you need to bind the > push-line widget to keystrokes in the vi mode keymap and then replace > "\eq" in the bindkey above with those keystrokes. Perhaps: > > bindkey -v > bindkey "^Xq" push-line > bindkey -s "^R" "^Xqhh\n" > > The other answer is that this should be written as a widget and should > not use the -s option of bindkey at all: > > invoke-hh() { hh zle -N invoke-hh > bindkey -M emacs "^R" invoke-hh > bindkey -M viins "^R" invoke-hh > > Since ^R is already bound to redisplay in vi-mode, you may want to choose > something else there. > > Important note: I didn't actually look at the configuration that hh is > adding to your startup files. If "hh" is being created as an alias, > then the widget implementation won't work (at least, not exactly as I > wrote it) and you'll have to stick with using "bindkey -s". > --047d7bdc0fd69cb9f7051b5e0627--