about summary refs log tree commit diff
path: root/Functions/Zle/down-line-or-beginning-search
diff options
context:
space:
mode:
authorPaul Ackersviller <packersv@users.sourceforge.net>2007-11-25 00:35:23 +0000
committerPaul Ackersviller <packersv@users.sourceforge.net>2007-11-25 00:35:23 +0000
commit4ecf5b41ea3cb730fb726064461e83dd19a63563 (patch)
treeedbc031cda04242a1089466346fa13241724ed00 /Functions/Zle/down-line-or-beginning-search
parent1d77e36c393be4fa8d836104b6ff2d6bdcfad134 (diff)
downloadzsh-4ecf5b41ea3cb730fb726064461e83dd19a63563.tar.gz
zsh-4ecf5b41ea3cb730fb726064461e83dd19a63563.tar.xz
zsh-4ecf5b41ea3cb730fb726064461e83dd19a63563.zip
Merge of users/11790: avoid nounset.
Diffstat (limited to 'Functions/Zle/down-line-or-beginning-search')
-rw-r--r--Functions/Zle/down-line-or-beginning-search21
1 files changed, 21 insertions, 0 deletions
diff --git a/Functions/Zle/down-line-or-beginning-search b/Functions/Zle/down-line-or-beginning-search
new file mode 100644
index 000000000..fbd2c3341
--- /dev/null
+++ b/Functions/Zle/down-line-or-beginning-search
@@ -0,0 +1,21 @@
+# Like down-line-or-search, but uses the whole line prefix up to the
+# cursor position for searching forwards.
+
+emulate -L zsh
+
+if [[ ${+NUMERIC} -eq 0 &&
+    ( $LASTWIDGET = $__searching || $RBUFFER != *$'\n'* ) ]]
+then
+  [[ $LASTWIDGET = $__searching ]] && CURSOR=$__savecursor
+  __searching=$WIDGET
+  __savecursor=$CURSOR
+  if zle .history-beginning-search-forward; then
+    [[ $RBUFFER = *$'\n'* ]] || 
+	zstyle -T ':zle:down-line-or-beginning-search' leave-cursor &&
+	zle .end-of-line
+    return
+  fi
+  [[ $RBUFFER = *$'\n'* ]] || return
+fi
+__searching=''
+zle .down-line-or-history