Re: [Fish-users] Adding functions to share/functions: acceptability?

2017-12-11 Thread David Guyot
Le vendredi 08 décembre 2017 à 21:57 +, Michael Stillwell a écrit :
> On Fri, Dec 8, 2017 at 9:41 PM, David Adam  > wrote:
> 
> > >    3. which directory should I place such functions in, on an
> > > installed
> > >   fish instance, to test them? ~/.config/fish/functions?
> > 
> > That's the easiest way!
> 
> You've probably discovered this, but sometimes fish doesn't pick up
> the changes to a script immediately; you can force fish to reprocess
> the file via e.g.
> 
> . ~/.config/fish/functions/foo.fish
> 
I did notice that; thanks for the tip. And thanks, David, for your
answers.
> 
> 
> 
> 
> Michael
-- 
David Guyot
Administrateur système / Sysadmin
Europe Camions Interactive / Stockway
Moulin Collot F-88500 Ambacourt
Tél : +33 (0)3 29 30 47 85

signature.asc
Description: This is a digitally signed message part
--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users


Re: [Fish-users] Adding functions to share/functions: acceptability?

2017-12-08 Thread Michael Stillwell
On Fri, Dec 8, 2017 at 9:41 PM, David Adam  wrote:

>>3. which directory should I place such functions in, on an installed
>>   fish instance, to test them? ~/.config/fish/functions?
>
> That's the easiest way!

You've probably discovered this, but sometimes fish doesn't pick up
the changes to a script immediately; you can force fish to reprocess
the file via e.g.

. ~/.config/fish/functions/foo.fish





Michael

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users


Re: [Fish-users] Adding functions to share/functions: acceptability?

2017-12-08 Thread David Adam
Hi David,

On Fri, 8 Dec 2017, David Guyot wrote:
> I'm working on completions for zfs and zpool commands, but there are
> some shared functions between them, for instance for zpool completions
> accepting zfs properties. On one hand, I'm reluctant to duplicate code,
> as it is likely that, when a copy will be improved, the other one will
> miss it; on the other hand, such functions could be helpful for other
> programs, like the ones listing available pools and properties.
> 
> For these reasons, I would like to migrate such functions in
> share/functions, but I have some questions:
>1. would it be right to place such helper functions in share/functions?

Yes. Generally these helper functions, which are not intended to be run 
directly by end-users, are called `__fish_print_{object}` or 
`__fish_complete_{object}`, depending on whether they return a simple list 
or a tab-separated list of items and descriptions.

If you only need the function for a single completion, it can go inside 
the completion itself as a standalone function.

>2. are there established criteria for judging the relevance of such
>   placements? For instance, accept functions only displaying lists of
>   suggestions, not altering the already typed-in command?

I'm not sure I understand the question here, but if you have a look in the 
source under `share/functions/__fish_*` you can see some examples. In 
general the completion framework changes the command line, rather than 
being directly done by functions or completions. (Functions bound to 
certain keys are another matter.)

>3. which directory should I place such functions in, on an installed
>   fish instance, to test them? ~/.config/fish/functions?

That's the easiest way!
 
> Please note that, for 1. and 3., I'm almost sure of the answer, but not
> totally, hence the questions.

Hope that helps.

David Adam
zanc...@ucc.gu.uwa.edu.au

--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Fish-users mailing list
Fish-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/fish-users