From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28260 invoked from network); 12 Nov 2004 10:43:08 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 12 Nov 2004 10:43:08 -0000 Received: (qmail 59446 invoked from network); 12 Nov 2004 10:43:02 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 12 Nov 2004 10:43:02 -0000 Received: (qmail 29478 invoked by alias); 12 Nov 2004 10:42:46 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 20552 Received: (qmail 29460 invoked from network); 12 Nov 2004 10:42:45 -0000 Received: from unknown (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 12 Nov 2004 10:42:45 -0000 Received: (qmail 58878 invoked from network); 12 Nov 2004 10:41:46 -0000 Received: from sodans.usata.org (61.211.239.46) by a.mx.sunsite.dk with SMTP; 12 Nov 2004 10:41:43 -0000 Received: from [157.82.5.146] (unknown [157.82.5.146]) by sodans.usata.org (Postfix) with ESMTP id ED1E1AAE0 for ; Fri, 12 Nov 2004 19:41:38 +0900 (JST) Mime-Version: 1.0 (Apple Message framework v619) To: zsh-workers@sunsite.dk Message-Id: <6CC830A4-3497-11D9-8EC5-000D93502E64@h8.dion.ne.jp> Content-Type: multipart/mixed; boundary=Apple-Mail-4--457672487 From: Motoi Washida Subject: Fink completion Date: Fri, 12 Nov 2004 19:41:35 +0900 X-Mailer: Apple Mail (2.619) X-Spam-Checker-Version: SpamAssassin 2.63 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, hits=1.0 required=6.0 tests=FROM_ENDS_IN_NUMS autolearn=no version=2.63 X-Spam-Hits: 1.0 --Apple-Mail-4--457672487 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed Hi, I wrote Fink completion. Fink is a package management system on Mac OS X. Could you add this completion to main zsh trunk if there is no problem? William Scott and Wataru Kagawa gave me advices to complete correctly. And could you add new completion I submitted before? http://www.zsh.org/mla/workers/2004/msg00923.html And I modified some files after that. -- Motoi Washida --Apple-Mail-4--457672487 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="_fink" Content-Disposition: attachment; filename=_fink #compdef fink _fink_get_packages_with_cache(){ local cache_policy zstyle -s ":completion:${curcontext}:" cache-policy cache_policy if [[ -z "$cache_policy" ]]; then zstyle ":completion:${curcontext}:" cache-policy _finkpkgs_caching_policy fi typeset -g -a _fink_pkgs local expl if ( (( #_fink_pkgs == 0 )) || _cache_invalid finkpkgs) \ && ! _retrieve_cache finkpkgs; then _fink_pkgs=(${(f)"$( command fink list --tab \ | command grep -v '\[virtual package\]' \ | command sed 's/^ / n /' \ | command cut -f1,2 )"}) _store_cache finkpkgs _fink_pkgs fi if (( # > 0 )); then local i for i in "$@"; do case "$i" in -i) packages+=(${${(M)_fink_pkgs:#?i?*}#* }) ;; -o) packages+=(${${(M)_fink_pkgs:#(i)*}#* }) ;; -n) packages+=(${${(M)_fink_pkgs:# n *}#* }) ;; esac done else packages=(${_fink_pkgs#* }) fi } _fink_get_packages_without_cache(){ local expl packages=(${(f)"$( command fink list -t "$@" "$PREFIX" \ | command grep -v '\[virtual package\]' \ | command cut -f2 )"}) } _fink_get_packages(){ # variable packages will be set if zstyle -t ":completion:${curcontext}:" use-cache; then _fink_get_packages_with_cache "$@" else _fink_get_packages_without_cache "$@" fi } _finkpkgs_caching_policy(){ oldp=( "$1"(Nmw+1) ) (( $#oldp )) || [[ /sw/var/cache/apt/pkgcache.bin -nt "$1" ]] || [[ /sw/var/lib/dpkg/available -nt "$1" ]] } _fink(){ local -a _1st_arguments _1st_arguments=( 'install:install or update packages' 'remove:remove packages' 'purge:remove packages and configuration files' 'update-all:update all installed packages to the latest version' 'list:search package name or conditions and list' 'apropos:search package descriptions or conditions and list' 'describe:display a description of the package' 'fetch:download package source files' 'fetch-all:downloads all package source files' 'fetch-missing:download all missing package source files' 'build:build .deb packages' 'rebuild:rebuild .deb packages' 'reinstall:reinstall packages' 'configure:rerun the fink configuration process' 'selfupdate:upgrade to a new fink release' 'validate:validate files' 'scanpackages:call dpkg-scanpackages' 'checksums:validate the MD5 digest of all tarballs' 'cleanup:removes obsolete package files' ) local context state line expl local -A opt_args _arguments \ '(-h --help)'{-h,--help}'[display help text]' \ '(-q --quiet)'{-q,--quiet}'[causes fink to be less verbose]' \ '(-V --version)'{-V,--version}'[display version information]' \ '(-v --verbose)'{-v,--verbose}'[causes fink to be more verbose]' \ '(-y --yes)'{-y,--yes}'[assume default answer for interactive questions]' \ '*:: :->subcmds' && return 0 if (( CURRENT == 1 )); then _describe -t commands "fink subcommand" _1st_arguments return fi local -a packages case "$words[1]" in install|update|enable|activate|use) _fink_get_packages -n -o _wanted packages expl 'not installed or outdated fink package' compadd -a packages ;; remove|disable|deactivate|unuse|delete|purge) _fink_get_packages -i _wanted packages expl 'installed package' compadd -a packages ;; #update-all) list) _arguments \ '(-t --tab)'{-t,--tab}'[outputs list with tabs as field delimiter]' \ '(-i --installed)'{-i,--installed}'[packages currently installed]' \ '(-u --uptodate)'{-u,--uptodate}'[packages up to date]' \ '(-o --outdate)'{-o,--outdated}'[packages newer version is available]' \ '(-n --notinstalled)'{-n,--notinstalled}'[packages not installed]' \ '(-b --buildonly)'{-b,--buildonly}'[packages Build Only Depends]' \ '(-s --section)'{-s=,--section=}'[sections]:section name' \ '(-m --maintainer)'{-m=,--maintainer=}'[maintainer]:maintainer name' \ --tree='[tree]:tree name' \ '(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \ '(1 : -)'{-h,--help}'[display help text]' \ '1: :->pkgs' && return 0 if [[ "$state" == pkgs ]]; then _fink_get_packages _wanted packages expl 'package name hint' compadd -a packages fi ;; apropos) _arguments \ '(-t --tab)'{-t,--tab}'[output the list with tabs as field delimiter]' \ '(-w --width)'{-w=,--width=}'[width of display]:number or "auto"' \ '(1 : -)'{-h,--help}'[display help text]' \ '1: :->pkgs' && return 0 if [[ "$state" == pkgs ]]; then _fink_get_packages _wanted packages expl 'package hint' compadd -a packages fi ;; describe|desc|description|info) _fink_get_packages _wanted packages expl 'package' compadd -a packages ;; #fetch) #fetch-all) fetch-missing) _arguments \ '(-i --ignore-restrictive)'{-i,--ignore-restrictive}'[do not fetch packages that are "License: Restrictive"]' ;; #build) rebuild|reinstall) _fink_get_packages _wanted packages expl 'package' compadd -a packages ;; #configure) #selfupdate) validate|check) _wanted files expl 'finkinfo file' _files -g \*.info ;; #scanpackages) #checksums) #cleanup) esac } _fink "$@" --Apple-Mail-4--457672487 Content-Transfer-Encoding: 7bit Content-Type: application/octet-stream; x-unix-mode=0644; name="completion_for_mac_2004_11_12.patch" Content-Disposition: attachment; filename=completion_for_mac_2004_11_12.patch diff -dur /Users/wm3/Desktop/hoge/_hdiutil Command/_hdiutil --- /Users/wm3/Desktop/hoge/_hdiutil Sat Oct 30 17:17:08 2004 +++ Command/_hdiutil Sat Nov 6 14:25:59 2004 @@ -4,11 +4,10 @@ # _hdiutil_disk() { local -a disk_desc - _call_program disks /bin/df | while read; do + _call_program devices hdiutil info | while read; do local disk_name="${${(M)REPLY[(w)1]%/dev/disk*}#/dev/}" - local mount_point="/${REPLY#*%*/}" - if [[ -n "$disk_name" && "$mount_point" != "/" ]]; then - disk_desc+=( $disk_name:$mount_point ) + if (( #disk_name )); then + disk_desc+=( "$disk_name:${${(M)REPLY% *}#?}" ) fi done _describe -t devices disks disk_desc diff -dur /Users/wm3/Desktop/hoge/_open Command/_open --- /Users/wm3/Desktop/hoge/_open Sat Oct 30 17:17:04 2004 +++ Command/_open Fri Nov 12 19:21:02 2004 @@ -3,8 +3,8 @@ _open_absolute_application_path() { local expl curcontext zstyle -T ":completion:${curcontext}:files" prefix-needed && \ - [[ "$PREFIX" != /* && compstate[nmatches] -ne 0 ]] && return 1 - _wanted files expl 'application file' _path_files -P / -W / + [[ "$PREFIX" != [/~]* && compstate[nmatches] -ne 0 ]] && return 1 + _wanted files expl 'application file' _path_files -P "$PREFIX[1]" -W / } _open() { @@ -13,6 +13,7 @@ _arguments -C \ '-a[specify application]: :->open_mac_applications' \ '-e[open with TextEdit]' \ + '-f[Reads input from standard input and opens with TextEdit]' \ '*: :->open_files' case "$state" in @@ -25,7 +26,7 @@ local app if [[ -n "$words[(r)-a]" ]]; then app="${(Q)words[words[(i)-a] + 1]}" - elif [[ -n "$words[(r)-e]" ]]; then + elif [[ -n "$words[(r)-e]" || -n "$words[(r)-f]" ]]; then app="Text Edit" fi if [[ -n "$app" ]]; then diff -dur /Users/wm3/Desktop/hoge/_mac_applications Type/_mac_applications --- /Users/wm3/Desktop/hoge/_mac_applications Sat Oct 30 17:17:14 2004 +++ Type/_mac_applications Fri Nov 12 19:19:28 2004 @@ -1,15 +1,6 @@ #autoload -_mac_applications() { - [[ $PREFIX = */* ]] && return 1 - - _retrieve_mac_apps - - local -a mac_apps - mac_apps=( ${_mac_apps[*]:t:r} ) - - local expl - _wanted commands expl 'Mac OS X application' compadd -a mac_apps -} +_retrieve_mac_apps -_mac_applications "$@" +local expl +_wanted commands expl 'Mac OS X application' compadd -- "${(@)${_mac_apps[@]:t}%.app}" diff -dur /Users/wm3/Desktop/hoge/_retrieve_mac_apps Type/_retrieve_mac_apps --- /Users/wm3/Desktop/hoge/_retrieve_mac_apps Sat Oct 30 21:49:30 2004 +++ Type/_retrieve_mac_apps Sat Nov 6 18:42:54 2004 @@ -26,7 +26,7 @@ then typeset -a app_dir_stop_pattern app_dir_root app_dir_stop_pattern=( "*.app" "contents#" "*data" "*plugins#" "*plug?ins#" "fonts#" "document[[:alpha:]]#" "*help" "resources#" "images#" "*configurations#" ) - app_dir_root=( {,/Developer,/Network,"$HOME"}/{Applications*,Desktop} ) + app_dir_root=( {,/Developer,/Network,"$HOME"}/{Applications*(N),Desktop} ) typeset app_dir_pattern app_dir_pattern="(^(#i)(${(j/|/)app_dir_stop_pattern}))" app_dir=( ${^app_dir_root}/(${~app_dir_pattern}/)#(N) ) @@ -41,12 +41,14 @@ _mac_apps+=( ${app_result[@]%/Contents/MacOS*} ) fi - # Get classic application files - if ! zstyle -t ":completion:${curcontext}:commands" ignore-classic; then + # Get single file applications + if ! zstyle -t ":completion:${curcontext}:commands" ignore-single; then autoload -U zargs - local app_cand - app_cand=( ${^app_dir}^*.[a-z]#(.UrN,.RN^U) ) - app_result="$(zargs --max-chars $((1024<<17)) ${^app_cand}/..namedfork/rsrc -- grep -l APPL)" + local app_cand nargs envvars + app_cand=( ${^app_dir}^*.[a-z]#/..namedfork/rsrc(.UrN,.RN^U) ) + envvars="$(builtin typeset -x)" + nargs=$(( $(command sysctl -n kern.argmax) - $#envvars - 2048 )) + app_result="$(zargs --max-chars $nargs ${app_cand[@]} -- grep -l APPL)" _mac_apps+=( ${${(f)app_result}%/..namedfork/rsrc} ) fi --Apple-Mail-4--457672487 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed --Apple-Mail-4--457672487--