vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit 92eb5c92ca6f1e665576d0d18c13c881216e0cb5
parent fd9f4d6496f556645fe7220e0d7aea6475cf43ec
Author: Randy Palamar <palamar@ualberta.ca>
Date:   Sat, 26 Aug 2023 14:54:22 -0600

support old option names but mark as deprecated

This is in response to a comment left on ed72b3d. Backwards compatibility
is a good idea for at least a release.

Diffstat:
Msam.c | 30++++++++++++++++++++----------
Mvis-cmds.c | 3+++
Mvis.h | 1+
3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/sam.c b/sam.c @@ -332,24 +332,32 @@ static const OptionDef options[] = { VIS_HELP("Number of spaces to display (and insert if `expandtab` is enabled) for a tab") }, [OPTION_SHOW_SPACES] = { - { "showspaces" }, - VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, + { "showspaces", "show-spaces" }, + VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW|VIS_OPTION_DEPRECATED, VIS_HELP("Display replacement symbol instead of a space") + NULL, + "show-spaces" }, [OPTION_SHOW_TABS] = { - { "showtabs" }, - VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, + { "showtabs", "show-tabs" }, + VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW|VIS_OPTION_DEPRECATED, VIS_HELP("Display replacement symbol for tabs") + NULL, + "show-tabs" }, [OPTION_SHOW_NEWLINES] = { - { "shownewlines" }, - VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, + { "shownewlines", "show-newlines" }, + VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW|VIS_OPTION_DEPRECATED, VIS_HELP("Display replacement symbol for newlines") + NULL, + "show-newlines" }, [OPTION_SHOW_EOF] = { - { "showeof" }, - VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW, + { "showeof", "show-eof" }, + VIS_OPTION_TYPE_BOOL|VIS_OPTION_NEED_WINDOW|VIS_OPTION_DEPRECATED, VIS_HELP("Display replacement symbol for lines after the end of the file") + NULL, + "show-eof" }, [OPTION_NUMBER] = { { "numbers", "nu" }, @@ -382,9 +390,11 @@ static const OptionDef options[] = { VIS_HELP("How to load existing files 'auto', 'read' or 'mmap'") }, [OPTION_CHANGE_256COLORS] = { - { "change256colors" }, - VIS_OPTION_TYPE_BOOL, + { "change256colors", "change-256colors" }, + VIS_OPTION_TYPE_BOOL|VIS_OPTION_DEPRECATED, VIS_HELP("Change 256 color palette to support 24bit colors") + NULL, + "change-256colors" }, [OPTION_LAYOUT] = { { "layout" }, diff --git a/vis-cmds.c b/vis-cmds.c @@ -185,6 +185,9 @@ static bool cmd_set(Vis *vis, Win *win, Command *cmd, const char *argv[], Select return false; } + if (opt->flags & VIS_OPTION_DEPRECATED && strcmp(opt->context, name) == 0) + vis_info_show(vis, "%s is deprecated and will be removed in the next release", name); + if (!win && (opt->flags & VIS_OPTION_NEED_WINDOW)) { vis_info_show(vis, "Need active window for `:set %s'", name); return false; diff --git a/vis.h b/vis.h @@ -857,6 +857,7 @@ enum VisOption { VIS_OPTION_TYPE_NUMBER = 1 << 2, VIS_OPTION_VALUE_OPTIONAL = 1 << 3, VIS_OPTION_NEED_WINDOW = 1 << 4, + VIS_OPTION_DEPRECATED = 1 << 5, }; /**