zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-users@zsh.org
Subject: Re: sound policy on global variables for "distributed" DWIM function
Date: Wed, 22 Jul 2015 18:41:30 -0700	[thread overview]
Message-ID: <150722184130.ZM327@torch.brasslantern.com> (raw)
In-Reply-To: <87zj2nsrjt.fsf@nl106-137-147.student.uu.se>

On Jul 23,  1:25am, Emanuel Berg wrote:
}
} But it doesn't have to be global outside the file
} where those couple of functions are defined.

Shells do not, generally speaking, have file-scoped variables.  You
get globals, variables that are local to functions, and the exported
process environment, and that's about it.

Howver, zsh does have yet another place to stash stuff like this:
The zstyle mechanism.  The ":completion:..." format is nothing but a
convention used in compsys; styles can actually look like anything
you want.

So you could have file names for contexts, e.g.

    zstyle '*/.zsh/dump' file-extension png

and then

    dump-vt () {
	local ext
	zstyle -s $HOME/.zsh/dump file-extension ext
	local file=$1.${ext:-png}
	# ... etc ...
    }

You could also have a different file-extension based on the current
working directory, or whatever.


      reply	other threads:[~2015-07-23  1:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-22  0:37 Emanuel Berg
2015-07-22 13:55 ` Joshua Krusell
2015-07-22 23:25   ` Emanuel Berg
2015-07-23  1:41     ` Bart Schaefer [this message]

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=150722184130.ZM327@torch.brasslantern.com \
    --to=schaefer@brasslantern.com \
    --cc=zsh-users@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).