vis
a vi-like editor based on Plan 9's structural regular expressions
git clone https://9o.is/git/vis.git
commit 45ab707e414964a0312ba27d8091755b9b1c2dfc parent 954129af9fab3606ba21039cd3f5a84575b5c8f6 Author: Marc André Tanner <mat@brain-dump.org> Date: Wed, 10 Sep 2014 14:12:53 +0200 If text has been created from an empty file, store filename upon first save Diffstat:
| M | text.c | | | 2 | ++ |
| M | text.h | | | 1 | + |
2 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/text.c b/text.c @@ -610,6 +610,8 @@ int text_save(Text *txt, const char *filename) { return -1; txt->saved_action = txt->undo; text_snapshot(txt); + if (!txt->filename) + txt->filename = strdup(filename); return 0; err: close(fd); diff --git a/text.h b/text.h @@ -27,6 +27,7 @@ typedef struct { text_iterator_next(&it)) Text *text_load(const char *file); +/* the filename from which this text was loaded or first saved to */ const char *text_filename(Text*); bool text_insert(Text*, size_t pos, const char *data); bool text_insert_raw(Text*, size_t pos, const char *data, size_t len);