From 90430089330f93b681450f6b25650f78e2ee34da Mon Sep 17 00:00:00 2001 From: Fabian Boehm Date: Wed, 18 Jan 2023 19:58:51 +0100 Subject: [PATCH] abbr: Clarify universal variable message And give explicit upgrade instructions. --- doc_src/cmds/abbr.rst | 13 +++++++++++++ src/builtins/abbr.cpp | 2 +- tests/checks/abbr.fish | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/doc_src/cmds/abbr.rst b/doc_src/cmds/abbr.rst index 7218263cf..af497760c 100644 --- a/doc_src/cmds/abbr.rst +++ b/doc_src/cmds/abbr.rst @@ -36,6 +36,19 @@ Combining these features, it is possible to create custom syntaxes, where a regu Previous versions of this allowed saving abbreviations in universal variables. That's no longer possible. Existing variables will still be imported and ``abbr --erase`` will also erase the variables. We recommend adding abbreviations to :ref:`config.fish ` by just adding the ``abbr --add`` command. + When you run ``abbr``, you will see output like this + + :: + + > abbr + abbr -a -- foo bar # imported from a universal variable, see `help abbr` + + In that case you should take the part before the ``#`` comment and save it in :ref:`config.fish `, + then you can run ``abbr --erase`` to remove the universal variable:: + + > abbr >> ~/.config/fish/config.fish + > abbr --erase (abbr --list) + "add" subcommand -------------------- diff --git a/src/builtins/abbr.cpp b/src/builtins/abbr.cpp index 026557ce8..7e202712e 100644 --- a/src/builtins/abbr.cpp +++ b/src/builtins/abbr.cpp @@ -99,7 +99,6 @@ static int abbr_show(const abbr_options_t &, io_streams_t &streams) { for (const auto &abbr : abbrs->list()) { comps.clear(); comps.push_back(L"abbr -a"); - if (abbr.from_universal) comps.push_back(L"-U"); if (abbr.is_regex()) { comps.push_back(L"--regex"); comps.push_back(escape_string(abbr.key)); @@ -122,6 +121,7 @@ static int abbr_show(const abbr_options_t &, io_streams_t &streams) { if (!abbr.replacement_is_function) { comps.push_back(escape_string(abbr.replacement)); } + if (abbr.from_universal) comps.push_back(_(L"# imported from a universal variable, see `help abbr`")); wcstring result = join_strings(comps, L' '); result.push_back(L'\n'); streams.out.append(result); diff --git a/tests/checks/abbr.fish b/tests/checks/abbr.fish index 17c549e9d..219afd6c8 100644 --- a/tests/checks/abbr.fish +++ b/tests/checks/abbr.fish @@ -4,7 +4,7 @@ set -U _fish_abbr_cuckoo somevalue set fish (status fish-path) $fish -c abbr -# CHECK: abbr -a -U -- cuckoo somevalue +# CHECK: abbr -a -- cuckoo somevalue # imported from a universal variable, see `help abbr` # Test basic add and list of __abbr1 abbr __abbr1 alpha beta gamma