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

Re: read timeout argument || completion of a function

On Aug 12, 12:43pm, Bruno Bonfils wrote:
} > The default completion is what is called when
} > there isn't any other completion defined, and it is implemented by a
} > function that is named _default, which happens to call another
} > function named _files.
} hmm ok, i understand now. So, in this case, it's possible to change
} the function which called by _default for only one command using
} zstyle ?

No, you cannot, using zstyle, change the functions which are called;
with zstyle you can change some of the function behaviors and in some
cases change the set of possible matches from which they select the list
of matching completions.  To change the functions called, use compdef.

} sure, in fact i have :
} % vi .zshrc
} ...
} source .zsh/rc/functions.rc
} fpath=($HOME/.zsh/functions $fpath)
} ...

And where in that sequence is your call to "compinit"?

} % vi .zsh/rc/functions.rc
} ...
} upgrade () {
}     if [ -z $1 ] ; then
}         sudo apt-get update
}         sudo apt-get -u upgrade
}     else
}         echo "sudo apt-get update" | ssh $1
}         # ask before the upgrade
}         local dummy
}         echo "sudo apt-get --no-act upgrade" | ssh $1
}         echo -n "Process the upgrade ?"
}         read -q dummy
}         if [[ $dummy == "y" ]] ; then
}             echo "sudo apt-get -u upgrade --yes"
}         fi
}     fi
} }

It looks like that always passes its argument to ssh.  So you can just:

	compdef upgrade=ssh

} upgrade <tab>
} file..
} _upgrade <tab>
} host..

I'm at a loss to explain this.  Have you tried using the _complete_help
and _complete_debug key bindings?  Man page excerpt:

_complete_debug (^X?)
     This widget performs ordinary completion, but captures in a
     temporary file a trace of the shell commands executed by the
     completion system.  Each completion attempt gets its own file.  A
     command to view each of these files is pushed onto the editor
     buffer stack.

_complete_help (^Xh)
     This widget displays information about the context names, the
     tags, and the completion functions used when completing at the
     current cursor position. If given a numeric argument other than 1
     (as in `ESC-2 ^Xh'), then the styles used and the contexts for
     which they are used will be shown, too.

     Note that the information about styles may be incomplete; it
     depends on the information available from the completion functions
     called, which in turn is determined by the user's own styles and
     other settings.

Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   

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