zsh-users
 help / color / mirror / code / Atom feed
* Vared with newlines between array elements
@ 2002-11-08 11:07 Peter Stephenson
  2002-11-11 20:21 ` Steve Talley
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Stephenson @ 2002-11-08 11:07 UTC (permalink / raw)
  To: Zsh users list

I just realised this trivial function is the answer to all my problems
with editing path and similar array variables with vared --- it puts
each element on a new line, so it's much easier to manipulate elements
separately.

To get filename completion to work properly, it should only require
backslashes before newlines and not other whitespace, nor anything else.
In other words, you get `/e/Program\ Files' from completion, but you
need `/e/Program Files' because vared preserves the backslash.
This could be fixed up if vared always stripped backslashes, which is
more symmetric since it always doubles existing backslashes (i.e. if you
had `/e/Program\ Files' to begin with it would have been quoted as
`/e/Program\\ Files' for editing.  However, the function is buried
inside the shell array splitting functions, so it's not entirely trivial
to fix without knock-on effects.

# Use vared with array elements joined by newlines.
# This makes reordering or removal of elements much simpler.
#
# With this function whitespace other than newlines in array elements
# should not be quoted by a backslash; this needs special completion
# handling (not currently provided).

local IFS='
'

vared "$@"
# End

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Vared with newlines between array elements
  2002-11-08 11:07 Vared with newlines between array elements Peter Stephenson
@ 2002-11-11 20:21 ` Steve Talley
  0 siblings, 0 replies; 2+ messages in thread
From: Steve Talley @ 2002-11-11 20:21 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh users list

Good tip.  I use:

# Use newlines to separate array elements in vared
alias vared='IFS="
" vared'

Steve

Peter Stephenson wrote:

> I just realised this trivial function is the answer to all my problems
> with editing path and similar array variables with vared --- it puts
> each element on a new line, so it's much easier to manipulate elements
> separately.
>
> To get filename completion to work properly, it should only require
> backslashes before newlines and not other whitespace, nor anything else.
> In other words, you get `/e/Program\ Files' from completion, but you
> need `/e/Program Files' because vared preserves the backslash.
> This could be fixed up if vared always stripped backslashes, which is
> more symmetric since it always doubles existing backslashes (i.e. if you
> had `/e/Program\ Files' to begin with it would have been quoted as
> `/e/Program\\ Files' for editing.  However, the function is buried
> inside the shell array splitting functions, so it's not entirely trivial
> to fix without knock-on effects.
>
> # Use vared with array elements joined by newlines.
> # This makes reordering or removal of elements much simpler.
> #
> # With this function whitespace other than newlines in array elements
> # should not be quoted by a backslash; this needs special completion
> # handling (not currently provided).
>
> local IFS='
> '
>
> vared "$@"
> # End


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-11-11 20:23 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-11-08 11:07 Vared with newlines between array elements Peter Stephenson
2002-11-11 20:21 ` Steve Talley

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).