Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: two completion problems.



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@xxxxxxxxxxxxxxxxxxx    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@xxxxxxxxxxxxxxxxxxx    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



Messages sorted by: Reverse Date, Date, Thread, Author