summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
authorChad Loder <cloder@cvs.openbsd.org>2005-05-28 01:53:38 +0000
committerChad Loder <cloder@cvs.openbsd.org>2005-05-28 01:53:38 +0000
commit25f01a945904da779dc25261b49b8e79b32b6fb9 (patch)
tree9a04986775e968930ce9467ac6a15865f0c557ba /usr.bin/mg
parente040b7721a597bd6782a33507893fd28fa99aeb5 (diff)
Dired now prompts in the minibuffer using the current directory name
or the name of the directory of the current buffer's file. OK kjell, jason
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/dired.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c
index 3aa7da5b06d..7f7e1194b56 100644
--- a/usr.bin/mg/dired.c
+++ b/usr.bin/mg/dired.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dired.c,v 1.18 2005/05/15 21:19:08 cloder Exp $ */
+/* $OpenBSD: dired.c,v 1.19 2005/05/28 01:53:37 cloder Exp $ */
/* dired module for mg 2a */
/* by Robert A. Larson */
@@ -115,7 +115,7 @@ int
dired(int f, int n)
{
static int inited = 0;
- char dirname[NFILEN], *bufp;
+ char dirname[NFILEN], *bufp, *slash;
BUFFER *bp;
if (inited == 0) {
@@ -123,8 +123,17 @@ dired(int f, int n)
inited = 1;
}
- dirname[0] = '\0';
- if ((bufp = eread("Dired: ", dirname, NFILEN, EFNEW | EFCR)) == NULL)
+ if (curbp->b_fname && curbp->b_fname[0] != '\0') {
+ strlcpy(dirname, curbp->b_fname, sizeof(dirname));
+ if ((slash = strrchr(dirname, '/')) != NULL) {
+ *(slash + 1) = '\0';
+ }
+ } else {
+ if (getcwd(dirname, sizeof(dirname)) == NULL)
+ dirname[0] = '\0';
+ }
+
+ if ((bufp = eread("Dired: ", dirname, NFILEN, EFDEF | EFNEW | EFCR)) == NULL)
return (ABORT);
if ((bp = dired_(bufp)) == NULL)
return (FALSE);