From 0e797d79ce0af34f20ec5fa86a4ed92554a968f9 Mon Sep 17 00:00:00 2001 From: Peter Stephenson Date: Fri, 1 May 2015 09:55:04 +0100 Subject: 35007: Note in doc about scope of ZLE parameters --- Doc/Zsh/zle.yo | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'Doc') diff --git a/Doc/Zsh/zle.yo b/Doc/Zsh/zle.yo index ffce54c84..653678eba 100644 --- a/Doc/Zsh/zle.yo +++ b/Doc/Zsh/zle.yo @@ -743,6 +743,21 @@ local scope, like parameters created in a function using tt(local). Inside completion widgets and traps called while ZLE is active, these parameters are available read-only. +Note that the parameters appear as local to any ZLE widget in +which they appear. Hence if it is desired to override them this needs +to be done within a nested function: + +example(widget-function+LPAR()+RPAR() { + # $WIDGET here refers to the special variable + # that is local inside widget-function + +LPAR()+RPAR() { + # This anonymous nested function allows WIDGET + # to be used as a local variable. The -h + # removes the special status of the variable. + local -h WIDGET + } +}) + startitem() vindex(BUFFER) item(tt(BUFFER) (scalar))( -- cgit 1.4.1