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 --- ChangeLog | 4 ++++ Doc/Zsh/zle.yo | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/ChangeLog b/ChangeLog index 2d2fb1b5a..0f563bd92 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2015-05-01 Peter Stephenson + + * 35007: Doc/Zsh/zle.yo: note about scope of ZLE parameters. + 2015-04-29 Peter Stephenson * 34992: Doc/Zsh/builtins.yo, Src/builtin.c, Src/params.c, 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