From d7777ed44e085ee809688379aef96dc05883b2fa Mon Sep 17 00:00:00 2001 From: Lars Henriksen Date: Sat, 25 Aug 2018 19:29:12 +0200 Subject: A save refinement: no action if everything is unchanged A reload action will do nothing if in-memory data as well as data files are unchanged. This commit accomplishes the equivalent for a save action. Because saving of configuration data and key bindings are mixed up with saving of data files, any changes in those will only be saved if data files also have changed. Hence, configuration data and key bindings are also saved upon exit from the configuration menu. Signed-off-by: Lars Henriksen Signed-off-by: Lukas Fleischer --- src/custom.c | 4 ++++ src/io.c | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/custom.c b/src/custom.c index fff83d7..8aa714d 100644 --- a/src/custom.c +++ b/src/custom.c @@ -1154,4 +1154,8 @@ void custom_config_main(void) wmove(win[STA].p, 0, 0); wins_doupdate(); } + if (!config_save()) + EXIT(_("Could not save %s."), path_conf); + if (!io_save_keys()) + EXIT(_("Could not save %s."), path_keys); } diff --git a/src/io.c b/src/io.c index d21b1fc..1ca2c2f 100644 --- a/src/io.c +++ b/src/io.c @@ -586,8 +586,12 @@ int io_save_cal(enum save_display display) if (read_only) return IO_SAVE_CANCEL; - if (new_data() && (ret = resolve_save_conflict())) - return ret; + if (new_data()) { + if ((ret = resolve_save_conflict())) + return ret; + } else + if (!io_get_modified()) + return IO_SAVE_CANCEL; run_hook("pre-save"); io_mutex_lock(); -- cgit v1.2.3-70-g09d2