Hi Stefano,
Sorry about the delay here. Hope you'll submit these completions once they
are done.
The proper way to do this is by putting each function in it's own file, e.g.
put
__lp_classes in
share/functions/__lp_classes.fish
After you do that, fish will autoload the __lp_classes function when it's
first used, and later unload it if it isn't used again. The strict 1:1
mapping between files and either completions or functions is so that fish
can later unload completions/functions that haven't been used for a while.
If fish didn't do this, a long running fish process would take several
megabytes of memory, which would be bad behaviour, especially since many
people run ten or fifteen shells in parallel.
Axel
2008/9/11 Stefano Sabatini <[email protected]>
> Hi all, I'm writing completion for lp* tools from the cups suite and
> I'm trying to include in each of the completion files a file
> containing the common commands named lpcommon.fish:
>
> ---------------------------8<---------------------------------
> #function shared by all the lp* tools completions
>
> function __lp_classes
> lpstat -c | sed -ne 's/^members of class \([^:]\+\):/\1/p'
> end
>
> function __lp_printers
> lpstat -p | sed -ne 's/^printer \([^ ]\+\).*/\1/p'
> end
>
> function __lp_jobs
> lpstat -o | cut -f1 -d" "
> end
> ---------------------------8<---------------------------------
>
> The I try to load it using . in a concrete completion file like this:
>
> -------------------------8<-------------------
> # completions for cups/lpstat 1.3.8
>
> # load common functions
> . lpcommon.fish
>
> complete -c lpstat -s E -d "Forces encryption when connecting to the
> server"
>
> complete -c lpstat -s R -d "Shows the ranking of print jobs"
>
> complete -c lpstat -s U -x -a '(__fish_complete_users)' -d "[USERNAME]
> Specifies an alternate username"
>
> complete -c lpstat -s p -f -a '(__lp_printers)' -d "[PRINTER(S)] Shows the
> printers and whether or not they are enabled for printing"
>
> complete -c lpstat -s W -x -a "all completed not-completed" -d
> "[WHICH-JOBS] Specifies which jobs to show"
>
> complete -c lpstat -s a -f -a "(__lp_printers)' -d "[PRINTER(S)] Shows the
> accepting state of printer queues"
>
> complete -c lpstat -s c -x -a '(__lp_classes)' -d "[CLASS(ES)] Shows the
> printer classes and the printers that belong to them"
>
> ...
> --------------------------8<---------------------------------------
>
> Unfortunately this doesn't seem to work, what I get for example with:
> lpstat -p ...
>
> stef...@geppetto ~> lpstat -p .: Error encountered while sourcing file
> "lpcommon.fish":
> .: No such file or directory
> fish: Unknown command "__lp_printers"
> Standard input: __lp_printers
> ^
> in command substitution
> called on standard input,
>
>
> stef...@geppetto ~> lpstat -p fish: Unknown command "__lp_printers"
> Standard input: __lp_printers
> ^
> in command substitution
> called on standard input,
>
>
> So I don't know which fish to take now ;-).
>
> Possible workarounds: to replicate all the function in each lp*
> completion file, but I'd prefer to avoid this.
>
> TIA (ye I'll post here completions when I'll be finished with 'em).
>
> Friendly regards.
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's
> challenge
> Build the coolest Linux based applications with Moblin SDK & win great
> prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> _______________________________________________
> Fish-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/fish-users
>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Fish-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fish-users