zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Zsh Hackers' List" <zsh-workers@zsh.org>
Subject: Re: PATCH: configurability of pattern characters, part 1
Date: Sat, 1 Jun 2013 21:18:36 +0100	[thread overview]
Message-ID: <20130601211836.550bd8ac@pws-pc.ntlworld.com> (raw)
In-Reply-To: <130531232223.ZM13592@torch.brasslantern.com>

On Fri, 31 May 2013 23:22:23 -0700
Bart Schaefer <schaefer@brasslantern.com> wrote:
> On Jun 1, 12:29am, Peter Stephenson wrote:
> }
> } The second step, to follow: now we have the "zpc_special" array, it will
> } be possible (and fairly straightforward) to introduce a special variable
> } to indicate pattern characters that should be turned off
> 
> Possible alternative idea -- use the enable/disable builtins?
> 
>     disable -p '^' '(' '+('

That's quite reasonable, it makes it more natural to enforce particular
entries than in an array.

The simple meaning for enable -p is that it reverses a disable, it
doesn't explicitly enable something that's not allowed by the options.
I think I'll stick with that (though it needs clearly documenting).  If
you want to be able to enable or disable every pattern separetely, you
"setopt extendedglob kshglob noshglob" first.

> } We'll need to set the new shell variable(s) locally to empty for
> } completion.
> 
> Hmm, that's another problem with the enable/disable idea ... or is it?
> "emulate -R zsh -c 'autoload _main_complete'" should do the trick ...?

Yes, it should, but that's another story I haven't written yet, so we
probably need another way...

"disable -p" should output the current settings, which we could save.
We reenable anything associated with extendedglob, turning off kshglob
and shglob using the options as now, and use disable -p to redisable the
user's stuff at the end in an "always" block.

Or how about readonly zsh/parameter arrays corresponding to enabled and
disabled patterns?  Same idea, just slightly more efficient to save.
(Could even be read/write; since they'd be documented as a front end to
enable/disable rather than the basic syntax the scoping behaviour isn't
so much of an issue.)

> } I think also "emulate" should clear them (locally for "emulate -L") to
> } present a pristine pattern environment for emulation.
> 
> I agree ... which for me is an argument *against* using variables for
> this.  I know emulation modes already play with the special-ness of
> things like HISTCHARS and MANPATH, but it doesn't actually go so far
> as creating empty locals for them.

The trouble is this creates an additional form of scope that's not
options or parameters or traps for saving and restoring.  However,
there's nothing fundamentally difficult about that.

Logically, to get emulate -L to behave as it does for options and traps,
there should be an option "localpatterns" that causes the effects of
disable -p to be restored after the current scope: otherwise we don't
have a natural distinction between the behaviour of "emulate" and
"emulate -L" (they'd have some hidden different effect on scoping, which
I don't like).  We just need to save one bit per pattern, so this is
much more efficient than what we currently do for localoptions.  In
other words, "setopt localpatterns" would mean "restore the disabled
pattern state at the end of the current function scope"; emulate's only
contribution would be to set this if -L was given and in any case turn
off the current disables.  That's exactly parallel to localoptions
except there's only one emulation state in this case, i.e. the one where
the patterns are controlled only by the option settings.
 
> Speaking of HISTCHARS, do we agree that it'd be a bad idea to be able
> to swap around which characters have what glob semantics?  E.g., it's
> OK if * means only "*", but you can't make % mean "match any number of
> any character".

Yes, I really don't think there's any sense in allowing this.  It causes
confusion far beyond any convenience it produces.

-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2013-06-01 20:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-05-31 23:29 Peter Stephenson
2013-06-01  6:22 ` Bart Schaefer
2013-06-01 20:18   ` Peter Stephenson [this message]
2013-06-02  7:16     ` Bart Schaefer
2013-06-03  8:40       ` Peter Stephenson
2013-06-03 15:05         ` Bart Schaefer
2013-06-03 15:31           ` Peter Stephenson
2013-06-01 23:09   ` PATCH: configurability of pattern characters, part 2 Peter Stephenson
2013-06-04  6:45     ` Bart Schaefer
2013-06-04  8:44       ` Peter Stephenson
2013-06-04 14:50         ` Bart Schaefer
2013-06-04 15:09           ` Peter Stephenson
2013-06-09 18:06         ` Peter Stephenson

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=20130601211836.550bd8ac@pws-pc.ntlworld.com \
    --to=p.w.stephenson@ntlworld.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).