From 773800e0de3598707dca49eb8206d6e38ca654aa Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Mon, 29 Sep 2008 17:40:54 +0000 Subject: 25733: stub function for dynamic directory name completion --- ChangeLog | 5 +++++ Completion/Zsh/Context/.distfiles | 1 + Completion/Zsh/Context/_dynamic_directory_name | 7 +++++++ Completion/Zsh/Context/_subscript | 11 ++++++++++- 4 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 Completion/Zsh/Context/_dynamic_directory_name diff --git a/ChangeLog b/ChangeLog index e1f7a96b5..b50654079 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-09-29 Peter Stephenson + * 25733: Completion/Zsh/Context/.distfiles, + Completion/Zsh/Context/_dynamic_directory_name, + Completion/Zsh/Context/_subscript: stub function for dynamic + directory name completion. + * 25772: Src/params.c: searching an associative array with a bad pattern could cause a crash, seen in _expand following "echo ~[]". diff --git a/Completion/Zsh/Context/.distfiles b/Completion/Zsh/Context/.distfiles index 8b4acfc7a..1537229f8 100644 --- a/Completion/Zsh/Context/.distfiles +++ b/Completion/Zsh/Context/.distfiles @@ -5,6 +5,7 @@ _autocd _brace_parameter _condition _default +_dynamic_directory_name _equal _first _in_vared diff --git a/Completion/Zsh/Context/_dynamic_directory_name b/Completion/Zsh/Context/_dynamic_directory_name new file mode 100644 index 000000000..85f8ff2ee --- /dev/null +++ b/Completion/Zsh/Context/_dynamic_directory_name @@ -0,0 +1,7 @@ +#autoload + +# The core libraries don't check for dynamic directory name expansion; +# this gets called from _subscript. This is a placeholder for +# people to overload. + +_message 'dynamic directory name: redefine _dynamic_directory_name to use' diff --git a/Completion/Zsh/Context/_subscript b/Completion/Zsh/Context/_subscript index 0b23c1cac..cef0a46e5 100644 --- a/Completion/Zsh/Context/_subscript +++ b/Completion/Zsh/Context/_subscript @@ -10,7 +10,16 @@ fi compset -P '\(([^\(\)]|\(*\))##\)' # remove subscript flags -if [[ "$PREFIX" = :* ]]; then +# Look for a dynamic name expansion. Completion only gives us +# the stuff inside the square brackets; we need to find out what's +# outside. We ought to check for quoting, really, but given we've +# got to the subscript code " ~[" is pretty likely to be a dynamic +# name expansion. +integer pos=$((CURSOR+1)) +while [[ pos > 1 && $BUFFER[pos-1] != '[' ]]; do (( pos-- )); done +if [[ $BUFFER[1,pos] = *[[:space:]]##\~\[ ]]; then + _dynamic_directory_name +elif [[ "$PREFIX" = :* ]]; then _wanted characters expl 'character class' \ compadd -p: -S ':]' alnum alpha ascii blank cntrl digit graph \ lower print punct space upper xdigit -- cgit 1.4.1