On Sat, Aug 19, 2017 at 9:33 PM, Kurtis Rader <kra...@skepticism.us> wrote:

> On Sat, Aug 19, 2017 at 6:42 PM, Mark Volkmann <r.mark.volkm...@gmail.com>
> wrote:
>
>> These are really cool utilities!
>> Let's see if I understand them correctly.
>> I can enter "funced foo" and create a new function named "foo".
>> I can immediate execute that by entering "foo".
>> But if I exit the session, I'll lose it.
>> I can enter "funcsave foo" and it will be written to
>> ~/.config/fish/functions/foo.fish.
>> Then it will be available in all future sessions.
>> Great!
>>
>> Later I can edit it again with "funced foo".
>> However, that just edits the in-memory version of the function.
>> It doesn't write the changes to the file unless I run "funcsave foo"
>> again.
>>
>> I was expecting that funced might realize the function was already saved
>> to a file and save the changes there. Either that or I thought there would
>> be a switch on funced to tell it to do that.
>>
>> I'm curious why neither of those is the way it works.
>>
>
> First, while `funced` can be used to create a function on the fly it's
> primary purpose is to edit an existing function. If I run `funced` more
> often than not I am testing something such as a change to my `fish_prompt`
> function. And because I'm testing something I do not want that change to be
> automatically reflected in the autoloaded script. If I do want a permanent
> change I can either run `funced` followed by `funcsave` or just directly
> edit the autoloaded script in ~/.config/fish/functions. Existing fish
> sessions will notice within  a few seconds that the script file has changed
> and reload it.
>

Thanks for explaining that! It looks like I can get what I want by writing
a function that does this:

  set fnpath $fish_function_path[1]
  funced $name; and funcsave $name; and source $fnpath/$name'.fish'

A related question:
Why does funced ask this question on exit?
"remove
/var/folders/jc/q4_2lrkd3pn2sz1l_s8rf31w0000gn/T//fish.DjETfi/baz.fish?"
Is that where it saves temporary (what I referred to as in-memory)
functions?
That isn't addressed in the help for funced.
I'm not sure how my answer to that question affects the function.


-- 
R. Mark Volkmann
Object Computing, Inc.
------------------------------------------------------------------------------
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

Reply via email to