zsh-workers
 help / color / mirror / code / Atom feed
* (:a) specifier for not existent files
@ 2012-07-18 13:12 Stefan Reichör
  2012-07-18 13:40 ` Peter Stephenson
  2012-07-18 14:42 ` Mikael Magnusson
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Reichör @ 2012-07-18 13:12 UTC (permalink / raw)
  To: zsh-workers

Hi,

I am using the (:a) specifier to get absoulte file paths. But this works
only for existing files. Is there a way to make it work for not existing
files also?

These are some experiments:

% echo .(:a)
/home/stefan/work
% echo tgz(:a)
/home/stefan/work/tgz
% echo tgz2(:a)
zsh: no matches found: tgz2(:a)


And here is the function that uses the above feature:

function ec
{
    emacsclient --no-wait $1(:a)
}


It would be nice to allow the creation of not existing files in emacsclient...


Thanks,
  Stefan.


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

* Re: (:a) specifier for not existent files
  2012-07-18 13:12 (:a) specifier for not existent files Stefan Reichör
@ 2012-07-18 13:40 ` Peter Stephenson
  2012-07-18 14:42 ` Mikael Magnusson
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Stephenson @ 2012-07-18 13:40 UTC (permalink / raw)
  To: zsh-workers

On Wed, 18 Jul 2012 15:12:49 +0200
Stefan Reichör <stefan@xsteve.at> wrote:
> I am using the (:a) specifier to get absoulte file paths. But this works
> only for existing files. Is there a way to make it work for not existing
> files also?

Not in general, because it can't sanity check the path so it doesn't
know what to do to it.  But you can handle some simple cases:

if [[ ! -e $1 ]]; then
  local dir=${1:h}
  if [[ -d $dir ]]; then
    dir=(${dir}(:a))
    1=${dir[1]}/${1:t}
  fi
fi

This works for names without a slash since ${1:h} returns ".".

-- 
Peter Stephenson <pws@csr.com>            Software Engineer
Tel: +44 (0)1223 692070                   Cambridge Silicon Radio Limited
Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, UK


Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom
More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog


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

* Re: (:a) specifier for not existent files
  2012-07-18 13:12 (:a) specifier for not existent files Stefan Reichör
  2012-07-18 13:40 ` Peter Stephenson
@ 2012-07-18 14:42 ` Mikael Magnusson
  1 sibling, 0 replies; 3+ messages in thread
From: Mikael Magnusson @ 2012-07-18 14:42 UTC (permalink / raw)
  To: Stefan Reichör; +Cc: zsh-workers

On 18/07/2012, Stefan Reichör <stefan@xsteve.at> wrote:
> Hi,
>
> I am using the (:a) specifier to get absoulte file paths. But this works
> only for existing files. Is there a way to make it work for not existing
> files also?
[...]
> function ec
> {
>     emacsclient --no-wait $1(:a)
> }

function ec
{
    emacsclient --no-wait $1:a
}


-- 
Mikael Magnusson


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

end of thread, other threads:[~2012-07-18 14:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-18 13:12 (:a) specifier for not existent files Stefan Reichör
2012-07-18 13:40 ` Peter Stephenson
2012-07-18 14:42 ` Mikael Magnusson

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