From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 1098 invoked by alias); 18 Jan 2016 19:29:07 -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: 37681 Received: (qmail 10376 invoked from network); 18 Jan 2016 19:29:05 -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=-1.9 required=5.0 tests=BAYES_00,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version:content-type; bh=ZTA6uFTg1l8orQ9h+5s6nD5BVKnl0+H/cziPi0kPJdM=; b=QO9RWdedGEU22sV+l6Z00NIoRam/RQZ7DQ+IZa1yiodj3e4RLsZLkKBeaus+7nbqGE nJ+U98yFKURL8G8jDfzZ8gc/pdyegLgAsozm1dV+/auOXY9uRXHC+Uz9M29QQEAcx3Cl FVd9RFhs0xDeRMVHeTXxU/WUSeDOxdN/7NUGSycbP0fWUIz8h7PznnHhMI1AdGVez3LC drLNkItkmtnscmaab1x3yu+5Kx9OyoKvYl9BEM5YPHIVoDwMYXsM9rNU+e42laPGyMqG pCvBkKAn/veJcrmxCN9R0obvavvjyq4zH8lN/sBHXotvbULGuCOGWmw7hv9MwnqHn7hk Eftw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=ZTA6uFTg1l8orQ9h+5s6nD5BVKnl0+H/cziPi0kPJdM=; b=VRXo4W3F640/5IcvATHGyFSWXAxr1xg5JAdO3zVdDe6Yd0C3s7ivzGjhx49ERZ8eFq lKdFP/oQMpLD8UxZ8+zcYSNOb11bwjBAD8z06V7kMNzQ94+Bwstc2tGX0N1Ui0kMFrQa sYgoBAxIT2rn4F2/P2JEhzoYu7WHEZu6CmwwtYwnTwQsLkIIPAxHHo+yO+H0+Szct0+C gthhfoaAsg/9eQyvQXHBpnIEnMs7q+P2fFigEmurNy3m92AyY+rPdDGGpmie0BC8p8kP /tQpFPX7dtn+7k4hCQ7Z/yFmbcUjhKLQiUkIIqsXSABzqT4ABMCdSuE990d5ZqCP7FpM iKvA== X-Gm-Message-State: ALoCoQnCdtD4hdI12s2D//zVW/TCrJYMvZak2g5xpriOIyTz9+rHx7Cc9TB8K497CMVrcz3BXxRjkU7e+33A2OYhYp5fnnLb2A== X-Received: by 10.66.252.198 with SMTP id zu6mr39089911pac.107.1453145342744; Mon, 18 Jan 2016 11:29:02 -0800 (PST) From: Bart Schaefer Message-Id: <160118112930.ZM6893@torch.brasslantern.com> Date: Mon, 18 Jan 2016 11:29:30 -0800 In-Reply-To: Comments: In reply to Krzysztof S0x0142onka "Re: Implementing search / reverse search in vi mode on input" (Jan 18, 6:45pm) References: X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: Zsh hackers list Subject: Re: Implementing search / reverse search in vi mode on input MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Jan 18, 6:45pm, Krzysztof wrote: } } The same way I can jump between words (normal mode + w, see: } http://vim.wikia.com/wiki/Moving_around) I would like to jump to search } phrase (normal mode + / word). Oh, I see, you want the search to include the current input buffer, not begin with the preceding history entry. I don't know why vi-* widgets don't already work that way when emacs widgets do. It might be sufficient to use one of the existing emacs builtin widgets such as history-incremental-search-backward. For more vi-like behavior, you can wrap those up with something like this (untested): autoload -Uz read-from-minibuffer vi-search-buffer-or-history() { emulate -L zsh local mbprompt REPLY if [[ $WIDGET = *-backward ]] then mbprompt='?' else mbprompt='/' fi # May want to install a custom keymap here zle read-from-minibuffer $mbprompt if [[ $WIDGET = *-backward ]] then zle .incremental-history-search-backward $REPLY else zle .incremental-history-search-forward $REPLY fi # Handle $? as appropriate here: # 0 the search succeeded # 1 the search failed # 2 the search term was a bad pattern # 3 the search was aborted by send-break } If you want even more control you can search the buffer yourself (this is also untested but should be a reasonable outline): vi-search-buffer-or-history() { emulate -L zsh local mbprompt REPLY found if [[ $WIDGET = *-backward ]] then mbprompt='?' else mbprompt='/' fi # May want to install a custom keymap here zle read-from-minibuffer $mbprompt if [[ $WIDGET = *-backward ]] then found=${(MS)LBUFFER%$~REPLY*} # (m) for multibyte characters here, may not be needed if [[ -n $found ]] then (( CURSOR -= ${(m)#found} )) else zle vi-history-search-backward $REPLY fi else found=${(MS)RBUFFER#*$~REPLY} # (m) for multibyte characters here, may not be needed if [[ -n $found ]] then (( CURSOR += ${(m)#found} )) # Theoretically there is no "forward" from the current buffer # else zle vi-history-search-forward $REPLY fi fi } Both of these would need handling of the LASTSEARCH parameter to allow repeated calls, I haven't gone into that detail.