about summary refs log tree commit diff
path: root/Functions/Zle/history-search-end
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-13 16:17:08 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-13 16:17:08 +0000
commitd2b14d6baa162305a2b1678fddb05b2d152a3cac (patch)
tree1266820c864db9dd7a7ac471f7cc4e02f29d7d1a /Functions/Zle/history-search-end
parent5dcad54926186c572d7dd653c1d621246048479f (diff)
downloadzsh-3.1.6-pws-4.tar.gz
zsh-3.1.6-pws-4.tar.xz
zsh-3.1.6-pws-4.zip
zsh-3.1.6-pws-4 zsh-3.1.6-pws-4
Diffstat (limited to 'Functions/Zle/history-search-end')
-rw-r--r--Functions/Zle/history-search-end28
1 files changed, 28 insertions, 0 deletions
diff --git a/Functions/Zle/history-search-end b/Functions/Zle/history-search-end
new file mode 100644
index 000000000..24e7a0a87
--- /dev/null
+++ b/Functions/Zle/history-search-end
@@ -0,0 +1,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
+# }