diff options
author | 2012-05-25 05:05:48 +0000 | |
---|---|---|
committer | 2012-05-25 05:05:48 +0000 | |
commit | 7f850f6abdada030060a7190a7991dadf582d33c (patch) | |
tree | cf6dc04e8ce294371defceb47d1fdd363029ff4a | |
parent | Remove static FILE pointer used for handling files in fileio.c. Pass (diff) | |
download | wireguard-openbsd-7f850f6abdada030060a7190a7991dadf582d33c.tar.xz wireguard-openbsd-7f850f6abdada030060a7190a7991dadf582d33c.zip |
Prepare mg buffers before startup file is parsed so multiple files can
be opened via the startup file. Having find-file, insert-file etc.. in
the startup file now work as you would expect.
Reviewed by Sunil Nimmagadda.
-rw-r--r-- | usr.bin/mg/main.c | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c index ce5f4049c51..5de9d53e790 100644 --- a/usr.bin/mg/main.c +++ b/usr.bin/mg/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.64 2012/04/12 04:47:59 lum Exp $ */ +/* $OpenBSD: main.c,v 1.65 2012/05/25 05:05:48 lum Exp $ */ /* This file is in the public domain. */ @@ -98,20 +98,29 @@ main(int argc, char **argv) */ update(); - /* user startup file */ - if ((cp = startupfile(NULL)) != NULL) - (void)load(cp); - /* * Create scratch buffer now, killing old *init* buffer. - * This causes *scratch* to be created and made curbp, - * ensuring default modes are inherited from the startup - * file correctly + * This causes *scratch* to be created and made curbp. */ - if ((bp = bfind("*init*", FALSE)) != NULL) killbuffer(bp); + /* user startup file. */ + if ((cp = startupfile(NULL)) != NULL) + (void)load(cp); + + /* + * Now ensure any default buffer modes from the startup file are + * given to any files opened when parsing the startup file. + * Note *scratch* will also be updated. + */ + for (bp = bheadp; bp != NULL; bp = bp->b_bufp) { + bp->b_flag = defb_flag; + for (i = 0; i <= defb_nmodes; i++) { + bp->b_modes[i] = defb_modes[i]; + } + } + /* Force FFOTHARG=1 so that this mode is enabled, not simply toggled */ if (init_fcn) init_fcn(FFOTHARG, 1); |