summary refs log tree commit diff
path: root/Functions/Zle/history-search-end
blob: 24e7a0a87371c7adb6ee96b2d463fc81b17a3d1f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# function history-search-end {
#
# This implements functions like history-beginning-search-{back,for}ward,
# but takes the cursor to the end of the line after moving in the
# history, like history-search-{back,for}ward.  To use them:
#   zle -N history-beginning-search-backward-end history-search-end
#   zle -N history-beginning-search-forward-end history-search-end
#   bindkey '...' history-beginning-search-backward-end
#   bindkey '...' history-beginning-search-forward-end

integer ocursor=$CURSOR

if [[ $LASTWIDGET = history-beginning-search-*-end ]]; then
  # Last widget called set $hbs_pos.
  CURSOR=$hbs_pos
else
  hbs_pos=$CURSOR
fi

if zle .${WIDGET%-end}; then
  # success, go to end of line
  zle .end-of-line
else
  # failure, restore position
  CURSOR=$ocursor
  return 1
fi
# }