Skip to content

warn if exiting fish with a unsaved but edited function #3701

Closed

Description

@nhooyr
  • Have you checked if problem occurs with fish 2.4.0?
  • Tried fish without third-party customizations (check sh -c 'env HOME=$(mktemp -d) fish')?

fish version installed (fish --version): 2.4.0

This would save me a lot of time. I always forget to save the function I just edited with funced :(

Activity

  1. krader1961 commented on Jan 6, 2017

    @krader1961
    Contributor

    I'm ambivalent about this proposal. Personally, I only use funced when I expressly want to make a transient change. If I want the change to be permanent I edit the underlying file and just let it be reloaded via the autoload mechanism. Rather than warn at exit time it would be simpler and safer, in my opinion, to modify funced to issue the warning after the user exits their editor. It would be best to write the warning only if the function was initially autoloaded but that will require implementing issue #3295.

  2. ridiculousfish commented on Jan 7, 2017

    @ridiculousfish
    Member

    How about an option to funced like --save which will run funcsave if the editor succeeds?

  3. krader1961 commented on Jan 8, 2017

    @krader1961
    Contributor

    Adding a -s / --save option is okay by me. However, I think a reminder message if the user didn't specify that option is still a good idea.

  4. floam commented on Jan 8, 2017

    @floam
    Member

    I agree. I know I lost a number of functions as a new fish user that could have been rescued with a helpful reminder.

  5. nhooyr commented on Jan 8, 2017

    @nhooyr
    ContributorAuthor

    @ridiculousfish how about an option to just straight up open the file in the editor?

  6. ridiculousfish commented on Jan 8, 2017

    @ridiculousfish
    Member

    @nhooyr funced prefers to use $EDITOR if set, is that what you mean?

  7. nhooyr commented on Jan 8, 2017

    @nhooyr
    ContributorAuthor

    @ridiculousfish but it opens a temporary file, I mean if a file exists for the function, it automatically opens that file in $EDITOR or if it doesn't, then it creates that file and opens that in $EDITOR. So no temp files if you set an option.

  8. krader1961 commented on Jan 8, 2017

    @krader1961
    Contributor

    if it doesn't, then it creates that file and opens that in $EDITOR.

    Do you propose to do that only if a specific option (e.g., the proposed --save option) is used or make that the default behavior?

  9. nhooyr commented on Jan 8, 2017

    @nhooyr
    ContributorAuthor

    Either is fine with me, I'll just alias it if we go with an option. However, I think most people would prefer that the behaviour I described above becomes the default behaviour and the other is hidden behind an option. I don't really edit functions I need temporarily and it's not like keeping them stored will take up a lot of resources or slow down the shell startup time.

  10. krader1961 commented on Jan 9, 2017

    @krader1961
    Contributor

    I don't think there is an overwhelming argument for either the current funced behavior to not automatically save the edit or the proposed behavior to do so. I think the tie-breaker is that changing existing default behavior should be avoided. So we should instead introduce something like a --perm / -p or --save / -s option pair to mean the edit should be persisted to the file system. And, as I said earlier, if that option isn't specified then display a reminder that the user may want to run funcsave to avoid losing their edit.

    Also, I feel like @nhooyr is missing the main reason for the current behavior. It makes it easy to test a change without worrying about accidentally breaking the version that is stored in the file system. That is, I can use funced to easily add some diagnostic printf statements or explore "what if" questions without having to first save a copy of the autoloaded script (or have it under version control). If I'm happy with the change I can then run funcsave to persist it to disk. So while I wholeheartedly agree that fish should remind the user that they will lose those changes unless they use one of the aforementioned solutions I don't want those edits to be persisted to an autoloaded script by default.

  11. krader1961 commented on Jan 10, 2017

    @krader1961
    Contributor

    Closing as a duplicate of issue #391. This issue discusses an aspect of the problem that was not previously discussed in #391 but it is essentially the same issue.

  12. locked as resolved and limited conversation to collaborators on Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions