zsh-workers
 help / color / mirror / code / Atom feed
* two completion problems.
@ 2007-03-01 14:12 Zvi Har'El
  2007-03-01 15:22 ` Peter Stephenson
  2007-03-01 15:29 ` Zvi Har'El
  0 siblings, 2 replies; 5+ messages in thread
From: Zvi Har'El @ 2007-03-01 14:12 UTC (permalink / raw)
  To: Zsh hackers list

Hi,

I am using the latest CVS have two completion problems: 
1) acroread completion fails:

~$ acroread <TAB>
_acroread:12: no such file or directory: line

The set -x output is below.


2) gnupg version 2 has its own binary. For the meantime, I copied _gpg to the
site_functions directory and changed the #compdef arguments to gpg2 and gpgv2.
But, a better solution will be to add these two arguments to the distributed
_gpg file.

Thanks,

Zvi.

============================================================
~$ acroread +_main_complete:7> local 'IFS= 
'
+_main_complete:21> eval 'setopt localoptions localtraps ${_comp_options[@]};
             local IFS=$'\'' \t\r\n\0'\''
             exec </dev/null;
             trap - ZERR'
+(eval):1> setopt localoptions localtraps bareglobqual extendedglob glob multiby
te nullglob rcexpandparam unset NO_allexport NO_aliases NO_cshnullglob NO_errexi
t NO_globsubst NO_histsubstpattern NO_kshglob NO_ksharrays NO_kshtypeset NO_mark
dirs NO_octalzeroes NO_shwordsplit NO_shglob NO_warncreateglobal
+(eval):2> local 'IFS= 
'
+(eval):4> trap - ZERR
+_main_complete:23> local func funcs 'ret=1' tmp _compskip format nm call match 
min max i num _completers _completer _completer_num curtag _comp_force_list _mat
chers _matcher _c_matcher _matcher_num _comp_tags _comp_mesg mesg str context st
ate line opt_args val_args 'curcontext=' '_last_nmatches=-1' _last_menu_style _d
ef_menu_style _menu_style sel '_tags_level=0' '_saved_exact=' '_saved_lastprompt
=yes' '_saved_list=ambiguous' '_saved_insert=automenu-unambiguous' '_saved_color
s='
+_main_complete:35> typeset -U _lastdescr _comp_ignore _comp_colors
+_main_complete:37> [[ -z '' ]]
+_main_complete:37> curcontext=::: 
+_main_complete:39> zstyle -s :completion::::: insert-tab tmp
+_main_complete:39> tmp=yes 
+_main_complete:41> [[ yes == '*pending(|[[:blank:]]*)' || yes == '*pending=(#b)
([0-9]##)(|[[:blank:]]*)' ]]
+_main_complete:49> [[ automenu-unambiguous == 'tab*' ]]
+_main_complete:59> [[ -z '' ]]
+_main_complete:60> [[ -o equals ]]
+_main_complete:60> compset -P 1 '='
+_main_complete:62> [[ '' != '*/*' && '' == '~' ]]
+_main_complete:70> _setup default
+_setup:3> local val 'nm=0'
+_setup:5> [[ 1 -eq 1 ]]
+_setup:5> 2=default 
+_setup:7> zstyle -a :completion:::::default list-colors val
+_setup:22> [[ default == default ]]
+_setup:23> unset ZLS_COLORS ZLS_COLOURS
+_setup:26> zstyle -t :completion:::::default list-packed
+_setup:28> [[ 2 -eq 1 ]]
+_setup:31> compstate[list]=ambiguous 
+_setup:34> zstyle -t :completion:::::default list-rows-first
+_setup:36> [[ 2 -eq 1 ]]
+_setup:39> compstate[list]=ambiguous 
+_setup:42> zstyle -t :completion:::::default last-prompt
+_setup:44> [[ 2 -eq 1 ]]
+_setup:47> compstate[last_prompt]=yes 
+_setup:50> zstyle -t :completion:::::default accept-exact
+_setup:52> [[ 2 -eq 1 ]]
+_setup:55> compstate[exact]='' 
+_setup:58> [[ _last_nmatches -ge 0 ]]
+_setup:61> zstyle -a :completion:::::default menu val
+_setup:65> _last_nmatches=-1 
+_setup:68> [[ '' != always ]]
+_setup:69> zstyle -s :completion:::::default force-list val
+_main_complete:71> _def_menu_style=( '' ) 
+_main_complete:80> _last_menu_style=( ) 
+_main_complete:82> zstyle -s :completion:::::default list-prompt tmp
+_main_complete:86> zstyle -s :completion:::::default select-prompt tmp
+_main_complete:90> zstyle -s :completion:::::default select-scroll tmp
+_main_complete:97> ((  0  ))
+_main_complete:109> zstyle -a :completion::::: completer _completers
+_main_complete:110> _completers=( _complete _ignored ) 
+_main_complete:115> _completer_num=1 
+_main_complete:119> funcs=( ) 
+_main_complete:120> compprefuncs=( ) 
+_main_complete:125> tmp=_complete
+_main_complete:127> [[ -n '' ]]
+_main_complete:129> [[ _complete == '*:-*' ]]
+_main_complete:132> [[ _complete == '*:*' ]]
+_main_complete:136> _completer=complete 
+_main_complete:139> curcontext=:complete:: 
+_main_complete:140> zstyle -t :completion::complete::: show-completer
+_main_complete:143> zstyle -a :completion::complete::: matcher-list _matchers
+_main_complete:144> _matchers=( '' ) 
+_main_complete:146> _matcher_num=1 
+_main_complete:147> _matcher='' 
+_main_complete:148> _c_matcher=
+_main_complete:149> [[ '' == '+*' ]]
+_main_complete:152> _matcher='' 
+_main_complete:155> _comp_mesg='' 
+_main_complete:156> [[ -n '' ]]
+_main_complete:161> _complete
+_complete:7> local comp name oldcontext 'ret=1' service
+_complete:8> typeset -T 'curcontext=:complete::' ccarray
+_complete:10> oldcontext=:complete:: 
+_complete:14> [[ -n '' ]]
+_complete:96> comp=_first 
+_complete:97> [[ -n _first ]]
+_complete:98> service=-first- 
+_complete:99> ccarray[3]=-first- 
+_complete:100> eval _first
+(eval):1> _first
+_complete:100> ret=0 
+_complete:101> [[ '' == all ]]
+_complete:110> [[ -n '' ]]
+_complete:114> ret=1 
+_complete:115> [[ command == command ]]
+_complete:116> curcontext=:complete:: 
+_complete:117> _normal -s
+_normal:3> local _comp_command1 _comp_command2 _comp_command skip
+_normal:5> [[ -s == -s ]]
+_normal:6> skip=( -s ) 
+_normal:14> [[ CURRENT -eq 1 ]]
+_normal:23> _set_command
+_set_command:6> local command
+_set_command:8> command=acroread 
+_set_command:10> [[ -z acroread ]]
+_set_command:12> ((  0 + 0  ))
+_set_command:15> [[ a == '=' ]]
+_set_command:19> [[ acroread == '..#/*' ]]
+_set_command:23> [[ acroread == '*/*' ]]
+_set_command:28> _comp_command1=acroread 
+_set_command:29> _comp_command2=/usr/local/bin/acroread 
+_set_command:30> _comp_command=acroread 
+_normal:25> _dispatch -s acroread acroread /usr/local/bin/acroread -default-
+_dispatch:3> local comp pat val name i 'ret=1' '_compskip='
+_dispatch:4> local 'curcontext=:complete::' service str noskip
+_dispatch:8> [[ -s == -s ]]
+_dispatch:9> noskip=yes 
+_dispatch:10> shift
+_dispatch:13> [[ -z yes ]]
+_dispatch:15> curcontext=:complete:acroread: 
+_dispatch:17> shift
+_dispatch:21> [[ '' != '(all|*patterns*)' ]]
+_dispatch:23> str=acroread
+_dispatch:24> [[ -n acroread ]]
+_dispatch:25> service=acroread 
+_dispatch:23> str=/usr/local/bin/acroread
+_dispatch:24> [[ -n /usr/local/bin/acroread ]]
+_dispatch:25> service=/usr/local/bin/acroread 
+_dispatch:23> str=-default-
+_dispatch:24> [[ -n -default- ]]
+_dispatch:25> service=-default- 
+_dispatch:40> ret=1 
+_dispatch:41> str=acroread
+_dispatch:42> [[ -n acroread ]]
+_dispatch:46> str=acroread 
+_dispatch:47> name=acroread 
+_dispatch:48> comp=_acroread 
+_dispatch:49> service=acroread 
+_dispatch:51> [[ -z _acroread ]]
+_dispatch:51> break
+_dispatch:56> [[ -n _acroread && acroread != -default- ]]
+_dispatch:57> _compskip=patterns 
+_dispatch:58> eval _acroread
+(eval):1> _acroread
+_acroread:3> local 'curcontext=:complete:acroread:' state line
+_acroread:7> local 'ver='
+_acroread:8> [[ -n '' ]]
+_acroread:10> ((  ! 0  ))
+_acroread:1> acroread -help
+_acroread:11> local 'acropath=line'

_acroread:12: no such file or directory: line
+_acroread:12> _acroread_version=
+_dispatch:59> [[ patterns == '(all|*patterns*)' ]]
+_dispatch:59> return ret
+_complete:142> _compskip='' 
+_complete:144> return ret
+_main_complete:165> ((  _matcher_num++  ))
+_main_complete:167> [[ -n '' ]]
+_main_complete:169> ((  _completer_num++  ))
+_main_complete:125> tmp=_ignored
+_main_complete:127> [[ -n '' ]]
+_main_complete:129> [[ _ignored == '*:-*' ]]
+_main_complete:132> [[ _ignored == '*:*' ]]
+_main_complete:136> _completer=ignored 
+_main_complete:139> curcontext=:ignored:: 
+_main_complete:140> zstyle -t :completion::ignored::: show-completer
+_main_complete:143> zstyle -a :completion::ignored::: matcher-list _matchers
+_main_complete:144> _matchers=( '' ) 
+_main_complete:146> _matcher_num=1 
+_main_complete:147> _matcher='' 
+_main_complete:148> _c_matcher=
+_main_complete:149> [[ '' == '+*' ]]
+_main_complete:152> _matcher='' 
+_main_complete:155> _comp_mesg='' 
+_main_complete:156> [[ -n '' ]]
+_main_complete:161> _ignored
+_ignored:5> [[ _matcher_num -gt 1 || 0 -eq 0 ]]
+_ignored:5> return 1
+_main_complete:165> ((  _matcher_num++  ))
+_main_complete:167> [[ -n '' ]]
+_main_complete:169> ((  _completer_num++  ))
+_main_complete:172> curcontext=::: 
+_main_complete:173> [[ '' == keep ]]
+_main_complete:179> nm=0 
+_main_complete:182> [[ '' == keep || nm -gt 1 ]]
+_main_complete:297> [[ nm -lt 1 && -n '' ]]
+_main_complete:300> [[ nm -eq 0 && -z '' && 0 -ne 0 ]]
+_main_complete:320> [[ '' == always || '' == '?*' ]]
+_main_complete:324> [[ '' == keep ]]
+_main_complete:326> ((  0  ))
+_main_complete:329> unset ZLS_COLORS
+_main_complete:334> funcs=( ) 
+_main_complete:335> comppostfuncs=( ) 
+_main_complete:340> _lastcomp=( list_lines 0 all_quotes '\' nmatches 0 restore 
auto context command vared '' unambiguous '' list_max 100 unambiguous_cursor 1 l
ist ambiguous insert_positions '' unambiguous_positions '' exact '' to_end match
 last_prompt yes pattern_insert menu ignored 0 insert automenu-unambiguous ) 
+_main_complete:341> _lastcomp[nmatches]=0 
+_main_complete:342> _lastcomp[completer]=ignored 
+_main_complete:343> _lastcomp[prefix]='' 
+_main_complete:344> _lastcomp[suffix]='' 
+_main_complete:345> _lastcomp[iprefix]='' 
+_main_complete:346> _lastcomp[isuffix]='' 
+_main_complete:347> _lastcomp[qiprefix]='' 
+_main_complete:348> _lastcomp[qisuffix]='' 
+_main_complete:349> _lastcomp[tags]='' 
+_main_complete:351> return ret
========================================================================
-- 
Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    Department of Mathematics
tel:+972-54-4227607 icq:179294841    Technion - Israel Institute of Technology
fax:+972-4-8293388  http://www.math.technion.ac.il/~rl/    Haifa 32000, ISRAEL
"If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942)
                                Thursday, 11 Adar 5767,  1 March 2007,  4:04PM


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

* Re: two completion problems.
  2007-03-01 14:12 two completion problems Zvi Har'El
@ 2007-03-01 15:22 ` Peter Stephenson
  2007-03-01 15:44   ` Zvi Har'El
  2007-03-01 15:29 ` Zvi Har'El
  1 sibling, 1 reply; 5+ messages in thread
From: Peter Stephenson @ 2007-03-01 15:22 UTC (permalink / raw)
  To: Zsh hackers list

"Zvi Har'El" wrote:
> I am using the latest CVS have two completion problems: 
> 1) acroread completion fails:
> 
> ~$ acroread <TAB>
> _acroread:12: no such file or directory: line

We search for the path to acrobat in order to check its version number
with the following substitution ($words[1] will be "acroread" or some
modification thereof):

  ${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}

This only works if the path is the second word on the first non-empty
line.  I get '/usr/local/bin/acroread'.  Presumably this is different in
your version.

However, it's already been confused by that point by the substitution
    _acroread_version=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
I think that (M) is in the wrong place and this should be:
    _acroread_version=${${(M)${(f)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
I haven't checked when this got changed, but the previous version should
never have worked; parameter flags only apply (directly) to the current
level of substitution.

The following fixes that, and makes the test for whether we can
read the file on the second check safer.  (For me this test is
redundant since it refers to the same file we just checked, but
after fixing the version extraction it doesn't get that far.)

Index: Completion/X/Command/_acroread
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_acroread,v
retrieving revision 1.6
diff -u -r1.6 _acroread
--- Completion/X/Command/_acroread	26 Mar 2006 15:15:10 -0000	1.6
+++ Completion/X/Command/_acroread	1 Mar 2007 15:08:34 -0000
@@ -1,15 +1,25 @@
 #compdef acroread
 
 local curcontext="$curcontext" state line
+local cmdfile
 
-# Try extracting the version number directly from the executable.
-# (This will fail if the executable is a wrapper script for acroread.)
-local ver=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
-[[ -n $ver ]] && _acroread_version=$ver
-
-if (( ! $+_acroread_version )); then
-  local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
-  _acroread_version=${${${(Mf)"$(<$acropath)"}:#ver=*}##ver=}
+if [[ $words[1] = */* && -x $words[1] ]]; then
+  cmdfile=$words[1]
+elif [[ -x $commands[$words[1]] ]]; then
+  cmdfile=$commands[$words[1]]
+fi
+
+if [[ -z $_acroread_version ]]; then
+  # Try extracting the version number directly from the executable.
+  # (This will fail if the executable is a wrapper script for acroread.)
+  _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=}
+
+  if [[ -z $_acroread_version ]]; then
+    local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
+    if [[ -r $acropath ]]; then
+      _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=}
+    fi
+  fi
 fi
 
 if [[ $_acroread_version == 7.* ]]; then

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


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


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

* Re: two completion problems.
  2007-03-01 14:12 two completion problems Zvi Har'El
  2007-03-01 15:22 ` Peter Stephenson
@ 2007-03-01 15:29 ` Zvi Har'El
  1 sibling, 0 replies; 5+ messages in thread
From: Zvi Har'El @ 2007-03-01 15:29 UTC (permalink / raw)
  To: Zsh hackers list

Looking again at the acroread problem, I noticed the parantheical remark at
_acroread, 

# Try extracting the version number directly from the executable.
# (This will fail if the executable is a wrapper script for acroread.)


I am using the AdobeReader_enu-7.0.9-1.i386.rpm from Adobe, and acroread IS a
shell script! However, just to what the version is, it is enough to run 
    
    acroread -version

I don't know about older version, but for my version the following patch will
do:
===============================================================================
--- /usr/local/src/build/zsh/Completion/X/Command/_acroread     2007-03-01 17:19:53.000000000 +0200
+++ /usr/local/share/zsh/4.3.2-dev-1/functions/_acroread        2007-02-28 16:06:27.000000000 +0200
@@ -2,7 +2,15 @@
 
 local curcontext="$curcontext" state line
 
-_acroread_version=$(eval $command -version)
+# Try extracting the version number directly from the executable.
+# (This will fail if the executable is a wrapper script for acroread.)
+local ver=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
+[[ -n $ver ]] && _acroread_version=$ver
+
+if (( ! $+_acroread_version )); then
+  local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
+  _acroread_version=${${${(Mf)"$(<$acropath)"}:#ver=*}##ver=}
+fi
 
 if [[ $_acroread_version == 7.* ]]; then
   _arguments -C \
==============================================================================
I haven't checked acroread version 6 or below.



On Thu, 01 Mar 2007 16:12:10 +0200, Zvi Har'El wrote about "two completion problems.":
> Hi,
> 
> I am using the latest CVS have two completion problems: 
> 1) acroread completion fails:
> 
> ~$ acroread <TAB>
> _acroread:12: no such file or directory: line
> 
> The set -x output is below.
> 
> 
> 2) gnupg version 2 has its own binary. For the meantime, I copied _gpg to the
> site_functions directory and changed the #compdef arguments to gpg2 and gpgv2.
> But, a better solution will be to add these two arguments to the distributed
> _gpg file.
> 
> Thanks,
> 
> Zvi.
> 
> ============================================================
> ~$ acroread +_main_complete:7> local 'IFS= 
> '
> +_main_complete:21> eval 'setopt localoptions localtraps ${_comp_options[@]};
>              local IFS=$'\'' \t\r\n\0'\''
>              exec </dev/null;
>              trap - ZERR'
> +(eval):1> setopt localoptions localtraps bareglobqual extendedglob glob multiby
> te nullglob rcexpandparam unset NO_allexport NO_aliases NO_cshnullglob NO_errexi
> t NO_globsubst NO_histsubstpattern NO_kshglob NO_ksharrays NO_kshtypeset NO_mark
> dirs NO_octalzeroes NO_shwordsplit NO_shglob NO_warncreateglobal
> +(eval):2> local 'IFS= 
> '
> +(eval):4> trap - ZERR
> +_main_complete:23> local func funcs 'ret=1' tmp _compskip format nm call match 
> min max i num _completers _completer _completer_num curtag _comp_force_list _mat
> chers _matcher _c_matcher _matcher_num _comp_tags _comp_mesg mesg str context st
> ate line opt_args val_args 'curcontext=' '_last_nmatches=-1' _last_menu_style _d
> ef_menu_style _menu_style sel '_tags_level=0' '_saved_exact=' '_saved_lastprompt
> =yes' '_saved_list=ambiguous' '_saved_insert=automenu-unambiguous' '_saved_color
> s='
> +_main_complete:35> typeset -U _lastdescr _comp_ignore _comp_colors
> +_main_complete:37> [[ -z '' ]]
> +_main_complete:37> curcontext=::: 
> +_main_complete:39> zstyle -s :completion::::: insert-tab tmp
> +_main_complete:39> tmp=yes 
> +_main_complete:41> [[ yes == '*pending(|[[:blank:]]*)' || yes == '*pending=(#b)
> ([0-9]##)(|[[:blank:]]*)' ]]
> +_main_complete:49> [[ automenu-unambiguous == 'tab*' ]]
> +_main_complete:59> [[ -z '' ]]
> +_main_complete:60> [[ -o equals ]]
> +_main_complete:60> compset -P 1 '='
> +_main_complete:62> [[ '' != '*/*' && '' == '~' ]]
> +_main_complete:70> _setup default
> +_setup:3> local val 'nm=0'
> +_setup:5> [[ 1 -eq 1 ]]
> +_setup:5> 2=default 
> +_setup:7> zstyle -a :completion:::::default list-colors val
> +_setup:22> [[ default == default ]]
> +_setup:23> unset ZLS_COLORS ZLS_COLOURS
> +_setup:26> zstyle -t :completion:::::default list-packed
> +_setup:28> [[ 2 -eq 1 ]]
> +_setup:31> compstate[list]=ambiguous 
> +_setup:34> zstyle -t :completion:::::default list-rows-first
> +_setup:36> [[ 2 -eq 1 ]]
> +_setup:39> compstate[list]=ambiguous 
> +_setup:42> zstyle -t :completion:::::default last-prompt
> +_setup:44> [[ 2 -eq 1 ]]
> +_setup:47> compstate[last_prompt]=yes 
> +_setup:50> zstyle -t :completion:::::default accept-exact
> +_setup:52> [[ 2 -eq 1 ]]
> +_setup:55> compstate[exact]='' 
> +_setup:58> [[ _last_nmatches -ge 0 ]]
> +_setup:61> zstyle -a :completion:::::default menu val
> +_setup:65> _last_nmatches=-1 
> +_setup:68> [[ '' != always ]]
> +_setup:69> zstyle -s :completion:::::default force-list val
> +_main_complete:71> _def_menu_style=( '' ) 
> +_main_complete:80> _last_menu_style=( ) 
> +_main_complete:82> zstyle -s :completion:::::default list-prompt tmp
> +_main_complete:86> zstyle -s :completion:::::default select-prompt tmp
> +_main_complete:90> zstyle -s :completion:::::default select-scroll tmp
> +_main_complete:97> ((  0  ))
> +_main_complete:109> zstyle -a :completion::::: completer _completers
> +_main_complete:110> _completers=( _complete _ignored ) 
> +_main_complete:115> _completer_num=1 
> +_main_complete:119> funcs=( ) 
> +_main_complete:120> compprefuncs=( ) 
> +_main_complete:125> tmp=_complete
> +_main_complete:127> [[ -n '' ]]
> +_main_complete:129> [[ _complete == '*:-*' ]]
> +_main_complete:132> [[ _complete == '*:*' ]]
> +_main_complete:136> _completer=complete 
> +_main_complete:139> curcontext=:complete:: 
> +_main_complete:140> zstyle -t :completion::complete::: show-completer
> +_main_complete:143> zstyle -a :completion::complete::: matcher-list _matchers
> +_main_complete:144> _matchers=( '' ) 
> +_main_complete:146> _matcher_num=1 
> +_main_complete:147> _matcher='' 
> +_main_complete:148> _c_matcher=
> +_main_complete:149> [[ '' == '+*' ]]
> +_main_complete:152> _matcher='' 
> +_main_complete:155> _comp_mesg='' 
> +_main_complete:156> [[ -n '' ]]
> +_main_complete:161> _complete
> +_complete:7> local comp name oldcontext 'ret=1' service
> +_complete:8> typeset -T 'curcontext=:complete::' ccarray
> +_complete:10> oldcontext=:complete:: 
> +_complete:14> [[ -n '' ]]
> +_complete:96> comp=_first 
> +_complete:97> [[ -n _first ]]
> +_complete:98> service=-first- 
> +_complete:99> ccarray[3]=-first- 
> +_complete:100> eval _first
> +(eval):1> _first
> +_complete:100> ret=0 
> +_complete:101> [[ '' == all ]]
> +_complete:110> [[ -n '' ]]
> +_complete:114> ret=1 
> +_complete:115> [[ command == command ]]
> +_complete:116> curcontext=:complete:: 
> +_complete:117> _normal -s
> +_normal:3> local _comp_command1 _comp_command2 _comp_command skip
> +_normal:5> [[ -s == -s ]]
> +_normal:6> skip=( -s ) 
> +_normal:14> [[ CURRENT -eq 1 ]]
> +_normal:23> _set_command
> +_set_command:6> local command
> +_set_command:8> command=acroread 
> +_set_command:10> [[ -z acroread ]]
> +_set_command:12> ((  0 + 0  ))
> +_set_command:15> [[ a == '=' ]]
> +_set_command:19> [[ acroread == '..#/*' ]]
> +_set_command:23> [[ acroread == '*/*' ]]
> +_set_command:28> _comp_command1=acroread 
> +_set_command:29> _comp_command2=/usr/local/bin/acroread 
> +_set_command:30> _comp_command=acroread 
> +_normal:25> _dispatch -s acroread acroread /usr/local/bin/acroread -default-
> +_dispatch:3> local comp pat val name i 'ret=1' '_compskip='
> +_dispatch:4> local 'curcontext=:complete::' service str noskip
> +_dispatch:8> [[ -s == -s ]]
> +_dispatch:9> noskip=yes 
> +_dispatch:10> shift
> +_dispatch:13> [[ -z yes ]]
> +_dispatch:15> curcontext=:complete:acroread: 
> +_dispatch:17> shift
> +_dispatch:21> [[ '' != '(all|*patterns*)' ]]
> +_dispatch:23> str=acroread
> +_dispatch:24> [[ -n acroread ]]
> +_dispatch:25> service=acroread 
> +_dispatch:23> str=/usr/local/bin/acroread
> +_dispatch:24> [[ -n /usr/local/bin/acroread ]]
> +_dispatch:25> service=/usr/local/bin/acroread 
> +_dispatch:23> str=-default-
> +_dispatch:24> [[ -n -default- ]]
> +_dispatch:25> service=-default- 
> +_dispatch:40> ret=1 
> +_dispatch:41> str=acroread
> +_dispatch:42> [[ -n acroread ]]
> +_dispatch:46> str=acroread 
> +_dispatch:47> name=acroread 
> +_dispatch:48> comp=_acroread 
> +_dispatch:49> service=acroread 
> +_dispatch:51> [[ -z _acroread ]]
> +_dispatch:51> break
> +_dispatch:56> [[ -n _acroread && acroread != -default- ]]
> +_dispatch:57> _compskip=patterns 
> +_dispatch:58> eval _acroread
> +(eval):1> _acroread
> +_acroread:3> local 'curcontext=:complete:acroread:' state line
> +_acroread:7> local 'ver='
> +_acroread:8> [[ -n '' ]]
> +_acroread:10> ((  ! 0  ))
> +_acroread:1> acroread -help
> +_acroread:11> local 'acropath=line'
> 
> _acroread:12: no such file or directory: line
> +_acroread:12> _acroread_version=
> +_dispatch:59> [[ patterns == '(all|*patterns*)' ]]
> +_dispatch:59> return ret
> +_complete:142> _compskip='' 
> +_complete:144> return ret
> +_main_complete:165> ((  _matcher_num++  ))
> +_main_complete:167> [[ -n '' ]]
> +_main_complete:169> ((  _completer_num++  ))
> +_main_complete:125> tmp=_ignored
> +_main_complete:127> [[ -n '' ]]
> +_main_complete:129> [[ _ignored == '*:-*' ]]
> +_main_complete:132> [[ _ignored == '*:*' ]]
> +_main_complete:136> _completer=ignored 
> +_main_complete:139> curcontext=:ignored:: 
> +_main_complete:140> zstyle -t :completion::ignored::: show-completer
> +_main_complete:143> zstyle -a :completion::ignored::: matcher-list _matchers
> +_main_complete:144> _matchers=( '' ) 
> +_main_complete:146> _matcher_num=1 
> +_main_complete:147> _matcher='' 
> +_main_complete:148> _c_matcher=
> +_main_complete:149> [[ '' == '+*' ]]
> +_main_complete:152> _matcher='' 
> +_main_complete:155> _comp_mesg='' 
> +_main_complete:156> [[ -n '' ]]
> +_main_complete:161> _ignored
> +_ignored:5> [[ _matcher_num -gt 1 || 0 -eq 0 ]]
> +_ignored:5> return 1
> +_main_complete:165> ((  _matcher_num++  ))
> +_main_complete:167> [[ -n '' ]]
> +_main_complete:169> ((  _completer_num++  ))
> +_main_complete:172> curcontext=::: 
> +_main_complete:173> [[ '' == keep ]]
> +_main_complete:179> nm=0 
> +_main_complete:182> [[ '' == keep || nm -gt 1 ]]
> +_main_complete:297> [[ nm -lt 1 && -n '' ]]
> +_main_complete:300> [[ nm -eq 0 && -z '' && 0 -ne 0 ]]
> +_main_complete:320> [[ '' == always || '' == '?*' ]]
> +_main_complete:324> [[ '' == keep ]]
> +_main_complete:326> ((  0  ))
> +_main_complete:329> unset ZLS_COLORS
> +_main_complete:334> funcs=( ) 
> +_main_complete:335> comppostfuncs=( ) 
> +_main_complete:340> _lastcomp=( list_lines 0 all_quotes '\' nmatches 0 restore 
> auto context command vared '' unambiguous '' list_max 100 unambiguous_cursor 1 l
> ist ambiguous insert_positions '' unambiguous_positions '' exact '' to_end match
>  last_prompt yes pattern_insert menu ignored 0 insert automenu-unambiguous ) 
> +_main_complete:341> _lastcomp[nmatches]=0 
> +_main_complete:342> _lastcomp[completer]=ignored 
> +_main_complete:343> _lastcomp[prefix]='' 
> +_main_complete:344> _lastcomp[suffix]='' 
> +_main_complete:345> _lastcomp[iprefix]='' 
> +_main_complete:346> _lastcomp[isuffix]='' 
> +_main_complete:347> _lastcomp[qiprefix]='' 
> +_main_complete:348> _lastcomp[qisuffix]='' 
> +_main_complete:349> _lastcomp[tags]='' 
> +_main_complete:351> return ret
> ========================================================================
> -- 
> Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    Department of Mathematics
> tel:+972-54-4227607 icq:179294841    Technion - Israel Institute of Technology
> fax:+972-4-8293388  http://www.math.technion.ac.il/~rl/    Haifa 32000, ISRAEL
> "If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942)
>                                 Thursday, 11 Adar 5767,  1 March 2007,  4:04PM

-- 
Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    Department of Mathematics
tel:+972-54-4227607 icq:179294841    Technion - Israel Institute of Technology
fax:+972-4-8293388  http://www.math.technion.ac.il/~rl/    Haifa 32000, ISRAEL
"If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942)
                                Thursday, 11 Adar 5767,  1 March 2007,  5:10PM


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

* Re: two completion problems.
  2007-03-01 15:22 ` Peter Stephenson
@ 2007-03-01 15:44   ` Zvi Har'El
  2007-03-01 15:50     ` Peter Stephenson
  0 siblings, 1 reply; 5+ messages in thread
From: Zvi Har'El @ 2007-03-01 15:44 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: Zsh hackers list

I just noticed that I had a problem with acroread installation: I had both
/usr/local/bin/acroread, which was somehow empty and not executible, and later
in the path /usr/bin/acroread. While the former file was checked by the
completion script, the latter was executed. Fixing that, even the previous
function works. But the real question is: why don't use acroread -version
instead of trying to read the file?

On Thu, 01 Mar 2007 15:22:11 +0000, Peter Stephenson wrote about "Re: two completion problems.":
> "Zvi Har'El" wrote:
> > I am using the latest CVS have two completion problems: 
> > 1) acroread completion fails:
> > 
> > ~$ acroread <TAB>
> > _acroread:12: no such file or directory: line
> 
> We search for the path to acrobat in order to check its version number
> with the following substitution ($words[1] will be "acroread" or some
> modification thereof):
> 
>   ${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
> 
> This only works if the path is the second word on the first non-empty
> line.  I get '/usr/local/bin/acroread'.  Presumably this is different in
> your version.
> 
> However, it's already been confused by that point by the substitution
>     _acroread_version=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
> I think that (M) is in the wrong place and this should be:
>     _acroread_version=${${(M)${(f)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
> I haven't checked when this got changed, but the previous version should
> never have worked; parameter flags only apply (directly) to the current
> level of substitution.
> 
> The following fixes that, and makes the test for whether we can
> read the file on the second check safer.  (For me this test is
> redundant since it refers to the same file we just checked, but
> after fixing the version extraction it doesn't get that far.)
> 
> Index: Completion/X/Command/_acroread
> ===================================================================
> RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_acroread,v
> retrieving revision 1.6
> diff -u -r1.6 _acroread
> --- Completion/X/Command/_acroread	26 Mar 2006 15:15:10 -0000	1.6
> +++ Completion/X/Command/_acroread	1 Mar 2007 15:08:34 -0000
> @@ -1,15 +1,25 @@
>  #compdef acroread
>  
>  local curcontext="$curcontext" state line
> +local cmdfile
>  
> -# Try extracting the version number directly from the executable.
> -# (This will fail if the executable is a wrapper script for acroread.)
> -local ver=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
> -[[ -n $ver ]] && _acroread_version=$ver
> -
> -if (( ! $+_acroread_version )); then
> -  local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
> -  _acroread_version=${${${(Mf)"$(<$acropath)"}:#ver=*}##ver=}
> +if [[ $words[1] = */* && -x $words[1] ]]; then
> +  cmdfile=$words[1]
> +elif [[ -x $commands[$words[1]] ]]; then
> +  cmdfile=$commands[$words[1]]
> +fi
> +
> +if [[ -z $_acroread_version ]]; then
> +  # Try extracting the version number directly from the executable.
> +  # (This will fail if the executable is a wrapper script for acroread.)
> +  _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=}
> +
> +  if [[ -z $_acroread_version ]]; then
> +    local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
> +    if [[ -r $acropath ]]; then
> +      _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=}
> +    fi
> +  fi
>  fi
>  
>  if [[ $_acroread_version == 7.* ]]; then
> 
> -- 
> Peter Stephenson <pws@csr.com>                  Software Engineer
> CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
> Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070
> 
> 
> To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php
> 
> To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview

-- 
Dr. Zvi Har'El      mailto:rl@math.technion.ac.il    Department of Mathematics
tel:+972-54-4227607 icq:179294841    Technion - Israel Institute of Technology
fax:+972-4-8293388  http://www.math.technion.ac.il/~rl/    Haifa 32000, ISRAEL
"If you can't say somethin' nice, don't say nothin' at all." -- Thumper (1942)
                                Thursday, 11 Adar 5767,  1 March 2007,  5:42PM


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

* Re: two completion problems.
  2007-03-01 15:44   ` Zvi Har'El
@ 2007-03-01 15:50     ` Peter Stephenson
  0 siblings, 0 replies; 5+ messages in thread
From: Peter Stephenson @ 2007-03-01 15:50 UTC (permalink / raw)
  To: Zsh hackers list

"Zvi Har'El" wrote:
> But the real question is: why don't use acroread -version
> instead of trying to read the file?

Indeed, I've folded that in as the default.

Index: Completion/X/Command/_acroread
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/X/Command/_acroread,v
retrieving revision 1.6
diff -u -r1.6 _acroread
--- Completion/X/Command/_acroread	26 Mar 2006 15:15:10 -0000	1.6
+++ Completion/X/Command/_acroread	1 Mar 2007 15:49:15 -0000
@@ -1,15 +1,29 @@
 #compdef acroread
 
 local curcontext="$curcontext" state line
+local cmdfile
 
-# Try extracting the version number directly from the executable.
-# (This will fail if the executable is a wrapper script for acroread.)
-local ver=${${${(Mf)"$(<$commands[$words[1]])"}:#ver=*}##ver=}
-[[ -n $ver ]] && _acroread_version=$ver
-
-if (( ! $+_acroread_version )); then
-  local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
-  _acroread_version=${${${(Mf)"$(<$acropath)"}:#ver=*}##ver=}
+if [[ -z $_acroread_version ]]; then
+  _acroread_version="$($words[1] -version 2>/dev/null)"
+fi
+
+if [[ -z $_acroread_version ]]; then
+  if [[ $words[1] = */* && -x $words[1] ]]; then
+    cmdfile=$words[1]
+  elif [[ -x $commands[$words[1]] ]]; then
+    cmdfile=$commands[$words[1]]
+  fi
+
+  # Try extracting the version number directly from the executable.
+  # (This will fail if the executable is a wrapper script for acroread.)
+  _acroread_version=${${(M)${(f)"$(<$cmdfile)"}:#ver=*}##ver=}
+
+  if [[ -z $_acroread_version ]]; then
+    local acropath=${${(s. .)${${(f)"$($words[1] -help 2>&1)"}[1]}}[2]}
+    if [[ -r $acropath ]]; then
+      _acroread_version=${${(M)${(f)"$(<$acropath)"}:#ver=*}##ver=}
+    fi
+  fi
 fi
 
 if [[ $_acroread_version == 7.* ]]; then

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


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php

To get further information regarding CSR, please visit our Investor Relations page at http://ir.csr.com/csr/about/overview


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

end of thread, other threads:[~2007-03-01 15:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-03-01 14:12 two completion problems Zvi Har'El
2007-03-01 15:22 ` Peter Stephenson
2007-03-01 15:44   ` Zvi Har'El
2007-03-01 15:50     ` Peter Stephenson
2007-03-01 15:29 ` Zvi Har'El

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