From 25f01a945904da779dc25261b49b8e79b32b6fb9 Mon Sep 17 00:00:00 2001 From: Chad Loder Date: Sat, 28 May 2005 01:53:38 +0000 Subject: 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 --- usr.bin/mg/dired.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'usr.bin/mg') 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); -- cgit v1.2.3