summaryrefslogtreecommitdiff
path: root/usr.bin/mg/file.c
diff options
context:
space:
mode:
authorVincent Labrecque <vincent@cvs.openbsd.org>2002-05-29 12:41:43 +0000
committerVincent Labrecque <vincent@cvs.openbsd.org>2002-05-29 12:41:43 +0000
commit72654f620c12e7d0fb15f20c99ee85298a14250f (patch)
treee83bc9753a67576605a8873d05fa4f7b69b48044 /usr.bin/mg/file.c
parent865bff097feb888c34fc0975b9df60143f406a49 (diff)
add an "auto-execute" feature, that allows binding function calls to
certain patterns. for example, `auto-execute "*.c" auto-indent-mode'. ok art@
Diffstat (limited to 'usr.bin/mg/file.c')
-rw-r--r--usr.bin/mg/file.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index a26922e4c22..8faabf4d8cd 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.17 2002/05/29 12:32:51 vincent Exp $ */
+/* $OpenBSD: file.c,v 1.18 2002/05/29 12:41:42 vincent Exp $ */
/*
* File commands.
@@ -128,13 +128,23 @@ readin(fname)
char *fname;
{
MGWIN *wp;
- int status;
+ int status, i;
+ PF *ael;
/* might be old */
if (bclear(curbp) != TRUE)
return TRUE;
status = insertfile(fname, fname, TRUE);
+ /*
+ * Call auto-executing function if we need to.
+ */
+ if ((ael = find_autoexec(fname)) != NULL) {
+ for (i = 0; ael[i] != NULL; i++)
+ (*ael[i])(0, 1);
+ free(ael);
+ }
+
/* no change */
curbp->b_flag &= ~BFCHG;
for (wp = wheadp; wp != NULL; wp = wp->w_wndp) {