about summary refs log tree commit diff
path: root/Completion
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:23:12 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-04-02 11:23:12 +0000
commit89583f9fd1b8a987d1c17b787cb69a307ad80d33 (patch)
treebfab10b1480b8323ac03f366871f9ce3d521fa8f /Completion
parent0fa297ae8d8456304f946c1b71495b1194388a9a (diff)
downloadzsh-89583f9fd1b8a987d1c17b787cb69a307ad80d33.tar.gz
zsh-89583f9fd1b8a987d1c17b787cb69a307ad80d33.tar.xz
zsh-89583f9fd1b8a987d1c17b787cb69a307ad80d33.zip
moved from Completion/Base/_first
Diffstat (limited to 'Completion')
-rw-r--r--Completion/Zsh/Context/_first47
1 files changed, 47 insertions, 0 deletions
diff --git a/Completion/Zsh/Context/_first b/Completion/Zsh/Context/_first
new file mode 100644
index 000000000..4b565fca4
--- /dev/null
+++ b/Completion/Zsh/Context/_first
@@ -0,0 +1,47 @@
+#compdef -first-
+
+# This function is called at the very beginning before any other
+# function for a specific context.
+#
+# This just gives some examples of things you might want to do here.
+#
+#
+# Other things you can do here is to complete different things if the
+# word on the line matches a certain pattern. This example allows
+# completion of words from the history by adding two commas at the end 
+# and hitting TAB.
+#
+#     if [[ "$PREFIX" = *,, ]]; then
+#       local max i=1 expl opt
+#     
+#       PREFIX="$PREFIX[1,-2]"
+#       # If a numeric prefix is given, we use it as the number of
+#       # lines (multiplied by ten below) in the history to search.
+#       if [[ ${NUMERIC:-1} -gt 1 ]]; then
+#         max=$NUMERIC
+#         unset NUMERIC
+#       else
+#         # The default is to search the last 100 lines.
+#         max=10
+#       fi
+#       # We first search in the last ten words, then in the last
+#       # twenty words, and so on...
+#       while [[ i -le max ]]; do
+#         if zstyle -t ":completion:${curcontext}:history-words" sort; then
+#           opt=-J
+#         else
+#           opt=-V
+#         fi
+#         if _wanted "$opt" history-words expl "history ($n)" \
+#                compadd -Q - \
+#                    "${(@)${(@)historywords:#[\$'\"]*}[1,i*10]}"; then
+#           # We have found at least one matching word, so we switch
+#           # on menu-completion and make sure that no other
+#           # completion function is called by setting _compskip.
+#           compstate[insert]=menu
+#           _compskip=all
+#           return 0
+#         fi
+#         (( i++ ))
+#       done
+#     fi