funcsave: edit the whole file containing a function

Many functions ship in files with helper functions, and it is useful to
edit those too.

Closes #391.
This commit is contained in:
David Adam
2021-08-10 21:46:00 +08:00
parent 52eff27239
commit 8dd4c67db1
3 changed files with 47 additions and 4 deletions

View File

@@ -17,6 +17,8 @@ Description
If the ``$VISUAL`` environment variable is set, it will be used as the program to edit the function. If ``$VISUAL`` is unset but ``$EDITOR`` is set, that will be used. Otherwise, a built-in editor will be used. Note that to enter a literal newline using the built-in editor you should press :kbd:`Alt`\ +\ :kbd:`Enter`. Pressing :kbd:`Enter` signals that you are done editing the function. This does not apply to an external editor like emacs or vim.
``funced`` will try to edit the original file that a function is defined in, which might include variable definitions or helper functions as well. If changes cannot be saved to the original file, a copy will be created in the user's function directory.
If there is no function called ``NAME``, a new function will be created with the specified name.
- ``-e command`` or ``--editor command`` Open the function body inside the text editor given by the command (for example, ``-e vi``). The special command ``fish`` will use the built-in editor (same as specifying ``-i``).