From 514fae450a53d6887f07aae729348c8fbbb52225 Mon Sep 17 00:00:00 2001 From: Randy Palamar Date: Sat, 26 Aug 2023 14:54:22 -0600 Subject: support old option names but mark as deprecated This is in response to a comment left on a35e7ea. Backwards compatibility is a good idea for at least a release. --- sam.c | 30 ++++++++++++++++++++---------- vis-cmds.c | 3 +++ vis.h | 1 + 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/sam.c b/sam.c index a1e120c..db4627b 100644 --- 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 index f5f8d5b..bf567bf 100644 --- 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 index b4dce44..e0f6739 100644 --- 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, }; /** -- cgit v1.2.3