diff options
author | Chad Loder <cloder@cvs.openbsd.org> | 2005-05-27 08:52:31 +0000 |
---|---|---|
committer | Chad Loder <cloder@cvs.openbsd.org> | 2005-05-27 08:52:31 +0000 |
commit | 141f6c9496a550f50379a449e7eca41c9b368813 (patch) | |
tree | e83deba491a5479747ab582eb0e2bd917f7cdf4e | |
parent | 5ae6cd1060db9ededd174ac3a42926ed709e8c1c (diff) |
In find file, behave like emacs: the default starting directory for
completion is the directory of the current buffer's file, if any,
rather than the working directory from where you launched mg.
Prodding by reyk, ok reyk and fgont
-rw-r--r-- | usr.bin/mg/file.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c index 69dfd6d7159..a901f6e8d86 100644 --- a/usr.bin/mg/file.c +++ b/usr.bin/mg/file.c @@ -1,4 +1,4 @@ -/* $OpenBSD: file.c,v 1.33 2005/04/21 19:16:21 beck Exp $ */ +/* $OpenBSD: file.c,v 1.34 2005/05/27 08:52:30 cloder Exp $ */ /* * File commands. @@ -39,9 +39,18 @@ int filevisit(int f, int n) { BUFFER *bp; - char fname[NFILEN], *bufp, *adjf; + char fname[NFILEN], *bufp, *adjf, *slash; + + if (curbp->b_fname && curbp->b_fname[0] != '\0') { + strlcpy(fname, curbp->b_fname, sizeof(fname)); + if ((slash = strrchr(fname, '/')) != NULL) { + *(slash + 1) = '\0'; + } + } + else + fname[0] = '\0'; - bufp = eread("Find file: ", fname, NFILEN, EFNEW | EFCR | EFFILE); + bufp = eread("Find file: ", fname, NFILEN, EFNEW | EFCR | EFFILE | EFDEF); if (bufp == NULL) return (ABORT); else if (bufp[0] == '\0') |