### vim:ft=zsh:foldmethod=marker
### This is a frequent action, I'm using atag() for.
### Let's make this simpler to type.
###
### Frank Terbeck <ft@bewatermyfriend.org>
### Last-Modified: Fri Sep  5 13:14:57 2008
###
### URI: <http://ft.bewatermyfriend.org/comp/zsh.html>
###

emulate -L zsh
setopt extendedglob
setopt nullglob
setopt noksharrays

local file dryrun
local -i ret__
local -a opts

if [[ -z ${commands[ataglist]} ]] || \
   [[ ! -x ${commands[ataglist]} ]] ; then

   printf 'ataglist not found. Giving up.\n'
   return 1
fi

if [[ $1 == '-d' ]] ; then
    shift
    opts=(-f -d)
else
    opts=(-f)
fi

for file in "$@" ; do
    atag ${file} -e
    atag ${file} ${opts}    \
        al=${_al}           \
        ar=${_ar}           \
        tt=${_tt}           \
        tn=${_tnp}          \
        y=${_yr}            \
        g=${_gr}            \
        comp=${_comp}
    (( ret__ += $? ))
done

return ${ret__}