diff options
author | Kjell Wooding <kjell@cvs.openbsd.org> | 2006-06-01 05:07:40 +0000 |
---|---|---|
committer | Kjell Wooding <kjell@cvs.openbsd.org> | 2006-06-01 05:07:40 +0000 |
commit | 3f5f3310a1d7af5fa0fd65890d8d039abdc767f4 (patch) | |
tree | 2c1f9d92c9d354df784a6f06ef86ede2e6a65cf1 /usr.bin | |
parent | 264eaf0f6fe86440d621080f4273753e496c3c6c (diff) |
Initialize current window, and clear the readonly flag earlier in file
read process. This allows code in the autoexec path (i.e. ~/.mg) to
operate on the buffer, making ~/.mg files much more useful.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mg/file.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index e1aea606821..0adff5bf369 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.56 2006/06/01 01:41:49 kjell Exp $ */ +/* $OpenBSD: file.c,v 1.57 2006/06/01 05:07:39 kjell Exp $ */ /* This file is in the public domain. */ @@ -209,11 +209,22 @@ readin(char *fname) /* might be old */ if (bclear(curbp) != TRUE) return (TRUE); + /* Clear readonly. May be set by autoexec path */ + curbp->b_flag &=~ BFREADONLY; if ((status = insertfile(fname, fname, TRUE)) != TRUE) { ewprintf("File is not readable: %s", fname); return (FALSE); } + for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { + if (wp->w_bufp == curbp) { + wp->w_dotp = wp->w_linep = lforw(curbp->b_linep); + wp->w_doto = 0; + wp->w_markp = NULL; + wp->w_marko = 0; + } + } + /* * Call auto-executing function if we need to. */ @@ -225,14 +236,6 @@ readin(char *fname) /* no change */ curbp->b_flag &= ~BFCHG; - for (wp = wheadp; wp != NULL; wp = wp->w_wndp) { - if (wp->w_bufp == curbp) { - wp->w_dotp = wp->w_linep = lforw(curbp->b_linep); - wp->w_doto = 0; - wp->w_markp = NULL; - wp->w_marko = 0; - } - } /* * We need to set the READONLY flag after we insert the file, @@ -244,8 +247,6 @@ readin(char *fname) ro = TRUE; if (ro == TRUE) curbp->b_flag |= BFREADONLY; - else - curbp->b_flag &=~ BFREADONLY; if (startrow) gotoline(FFARG, startrow); |