summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLars Henriksen <LarsHenriksen@get2net.dk>2018-08-25 19:29:12 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2018-10-21 20:01:34 +0200
commitd7777ed44e085ee809688379aef96dc05883b2fa (patch)
tree3c4a73ae2206c7c8a50dbaed778298b726da2da9 /src
parent5ad0019b2326e4012299e36682669ca767f39cd4 (diff)
downloadcalcurse-d7777ed44e085ee809688379aef96dc05883b2fa.tar.gz
calcurse-d7777ed44e085ee809688379aef96dc05883b2fa.zip
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 <LarsHenriksen@get2net.dk> Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/custom.c4
-rw-r--r--src/io.c8
2 files changed, 10 insertions, 2 deletions
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();