zsh-workers
 help / color / mirror / code / Atom feed
From: Felipe Contreras <felipe.contreras@gmail.com>
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: zsh-workers@zsh.org
Subject: Re: zle messes up 'words' variable?
Date: Tue, 3 May 2011 20:36:37 +0300	[thread overview]
Message-ID: <BANLkTingDPW5XhRwQeLNQy=-rOA-7bNyXw@mail.gmail.com> (raw)
In-Reply-To: <110503073902.ZM15889@torch.brasslantern.com>

On Tue, May 3, 2011 at 5:39 PM, Bart Schaefer <schaefer@brasslantern.com> wrote:
> On May 3, 11:05am, Felipe Contreras wrote:
> }
> } The fact that it's documented as a special variable doesn't mean that
> } the behavior should be totally unexpected.
> }
> } 1) Without modifier
> }
> } Then 'words' can be re-used like any other variable.
> }
> } 2) With 'local' modifier
> }
> } Then modifying 'words' has an impact only on the current function, not
> } on the scope where the variable was defined as local.
>
> Ahh, I see the problem.  You haven't read the entire documentation.
> At the very top of (what in the info file is) section 19.2 is this
> paragraph (caps mine for emphasis):
>
>    Inside completion widgets, AND ANY FUNCTIONS CALLED FROM THEM, some
>    parameters have special meaning; outside these functions they are
>    not special to the shell in any way. These parameters are used to
>    pass information between the completion code and the completion
>    widget. Some of the builtin commands and the condition codes use or
>    change the current values of these parameters. Any existing values
>    will be hidden during execution of completion widgets; EXCEPT FOR
>    COMPSTATE, THE PARAMETERS ARE RESET ON EACH FUNCTION EXIT (INCLUDING
>    NESTED FUNCTION CALLS FROM WITHIN THE COMPLETION WIDGET) to the
>    values they had when the function was entered.
>
> In other words, these variable are always local in all scopes, unless
> they are explicitly declared otherwise (which in this case requires
> the use of typeset -h).  That's part of their special-ness, and is one
> of the things I assert is extremely unlikely to change.

Except that 'words' is not really acting as local, and 'local' should
be considered 'declared otherwise'. That's part of the weirdness.

> } 2.1) When using #compdef tag
> }
> } Then 'words' can be modified like any other variable.
>
> I thought you'd decided you were unable to reproduce this?  If you now
> *are* able to reproduce it, then *that* might be a bug.

That's true.

> } 3) With 'typedef -h'
> }
> } Then 'words' can be modified like any other variable.
> }
> } I was expecting an explanation of these discrepancies, and a way to
> } globally make 'words' work as expected without having to replace each
> } use of 'local' by 'typedef -h'.
>
> I apologize for not understanding the source of the mis-understanding.
> I was focusing on why #compdef might make a difference, not on the
> details of the actual scoping problem you perceived.

I see.

> } > If what you want to discuss is ways to fix bashcompinit so that the
> } > functions in bash completion work as expected, that's one thing.  If
> } > what you're asking is for the special-ness of "words" to be undone
> } > for completion in general, that's so unlikely to happen as to not be
> } > worth continuing.
> }
> } You are not good at compartmentalizing aren't you?
>
> I'm really disappointed in the way that mailing list discourse in
> general lately (and not just on this list) tends to rapidly descend
> into insults and ad-hominem attacks.  I've been watching the CentOS
> list collapse under the weight of this sort of thing and I plead that
> we try to avoid it here.

I didn't intend that as an insult; some people are good are
compartmentalizing, some people are not.

> } If you fix the issue with my example, you fix the issue with
> } bashcompinit. It's the same issue. Or "riddle" if that word makes you
> } more comfortable.
>
> No, it's not the same issue, because bashcompinit has responsibility
> for loading the bash completion functions in a way that makes them
> compatible.  That's not the same as first loading bashcompinit and
> then independently defining a new completion, though I lean toward
> the conclusion that use of the bash-compatible "complete" command is
> probably the correct place to fix this if it can be managed.

Well, bashcompinit is also a script. If my script can be fixed without
modifying _foo() or set_vars(), then the same fix can be applied to
bashcompinit:

+typeset -h words
 complete -F _foo foo

-- 
Felipe Contreras


  parent reply	other threads:[~2011-05-03 17:36 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-27  8:26 Felipe Contreras
2011-04-27  9:02 ` Jérémie Roquet
2011-04-27  9:11   ` Felipe Contreras
2011-04-27  9:51     ` Felipe Contreras
2011-04-27 15:06 ` Bart Schaefer
2011-04-28 20:19 ` Felipe Contreras
2011-04-29  3:31   ` Bart Schaefer
2011-05-02 18:11     ` Felipe Contreras
2011-05-03  1:42       ` Bart Schaefer
2011-05-03  8:05         ` Felipe Contreras
2011-05-03 14:39           ` Bart Schaefer
2011-05-03 15:04             ` Bart Schaefer
2011-05-03 17:41               ` Felipe Contreras
2011-05-04  0:39                 ` Bart Schaefer
2011-05-05 14:39                   ` Felipe Contreras
2011-05-05 16:24                     ` Bart Schaefer
2011-05-05 16:40                       ` Felipe Contreras
2011-05-05 19:38                         ` Bart Schaefer
2011-05-05 20:14                           ` Felipe Contreras
2011-05-05 21:12                             ` Nikolai Weibull
2011-05-03 17:36             ` Felipe Contreras [this message]
2011-05-04  0:56               ` Bart Schaefer
2011-05-05 14:48                 ` Felipe Contreras
2011-05-05 15:50                   ` Bart Schaefer
2011-05-05 15:55                     ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTingDPW5XhRwQeLNQy=-rOA-7bNyXw@mail.gmail.com' \
    --to=felipe.contreras@gmail.com \
    --cc=schaefer@brasslantern.com \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).