zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@ifh.de>
To: zsh-users@sunsite.auc.dk
Subject: Re: is there a mix of history-search-backward and history-beginning-search-backward
Date: Wed, 08 Sep 1999 17:27:57 +0200	[thread overview]
Message-ID: <199909081527.RAA19661@paris.ifh.de> (raw)
In-Reply-To: "Andy Spiegl"'s message of "Wed, 08 Sep 1999 15:02:13 +0200." <19990908150213.D4878@br-online.de>

Andy Spiegl wrote:
> A while ago I asked:
> > 
> > I want to bind to ^P a widget that acts like
> > history-beginning-search-backward, but always moves the cursor to the end
> > of the line, like history-search-backward does.  Or said the other way:
> > I want history-search-backward to look at more than the first word.
> > 
> > Do you know a way to get this behavior?
> 
> Does noone have any idea about this?

Sorry, I meant to try this and then got sidetracked into things like
applying patches.

I assume you're using zsh 3.1, in which case it's not so hard:
probably you need 3.1.6 for the $LASTWIDGET test to work, which is
crucial.  I've called the functions
history-beginning-search-{back,for}ward-end.  If you shorten the
names, you will need to change the pattern matched against
$LASTWIDGET, because the functions need to know that one of the two
was called last, and hence the position to compare up to is already
set.  (Wasted ten minutes wondering why an `if' with a missing `then'
didn't work.  I think we're too lenient with the syntax.)

I might put these in the Functions/Zle directory (after Bart has found out
whatever's wrong with them).


# function history-beginning-search-forward-end {
# history-beginning-search-forward, with cursor at end.

integer ocursor=$CURSOR stat

if [[ $LASTWIDGET = history-beginning-search-(back|for)ward-end ]]; then
  # Last widget called set $hbs_pos.
  CURSOR=$hbs_pos
else
  hbs_pos=$CURSOR
fi

if zle history-beginning-search-forward; then
  # success, go to end of line
  zle end-of-line
else
  # failure, restore position
  CURSOR=$ocursor
  return 1
fi
# }

# function history-beginning-search-backward-end {
# history-beginning-search-backward, with cursor at end.

integer ocursor=$CURSOR stat

if [[ $LASTWIDGET = history-beginning-search-(back|for)ward-end ]]; then
  # Last widget called set $hbs_pos.
  CURSOR=$hbs_pos
else
  hbs_pos=$CURSOR
fi

if zle history-beginning-search-backward; then
  # success, go to end of line
  zle end-of-line
else
  # failure, restore position
  CURSOR=$ocursor
  return 1
fi
# }

-- 
Peter Stephenson <pws@ifh.de>       Tel: +39 050 844536
WWW:  http://www.ifh.de/~pws/
Dipartimento di Fisica, Via Buonarroti 2, 56127 Pisa, Italy


  reply	other threads:[~1999-09-08 15:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-03 11:04 Andy Spiegl
1999-09-08 13:02 ` Andy Spiegl
1999-09-08 15:27   ` Peter Stephenson [this message]
1999-09-08 15:55     ` Andy Spiegl
1999-09-08 16:18       ` Oliver Kiddle
1999-09-08 16:58       ` unsubscribe tbabin@nortelnetworks.com Timothy Babin
1999-09-11 22:58     ` is there a mix of history-search-backward and history-beginning-search-backward Bart Schaefer
1999-09-08 15:55   ` Bart Schaefer

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=199909081527.RAA19661@paris.ifh.de \
    --to=pws@ifh.de \
    --cc=zsh-users@sunsite.auc.dk \
    /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).