summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlum <lum@cvs.openbsd.org>2013-05-28 18:35:11 +0000
committerlum <lum@cvs.openbsd.org>2013-05-28 18:35:11 +0000
commit928d9bfe197a85321ff2d0bb7e4e35e1898272dd (patch)
tree90a1186974e122328a4c4b021d47dcc9ef0a16c0
parentf466e34b6cf7ee43eddaeb37a86df3637b19e528 (diff)
In dired mode the commands:
dired-copy-file dired-rename-file dired-create-directory do not refresh the dired buffer. Now they do.
-rw-r--r--usr.bin/mg/dired.c35
1 files changed, 31 insertions, 4 deletions
diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c
index 59a21a990d9..c73bf97db42 100644
--- a/usr.bin/mg/dired.c
+++ b/usr.bin/mg/dired.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dired.c,v 1.53 2013/05/27 18:24:44 lum Exp $ */
+/* $OpenBSD: dired.c,v 1.54 2013/05/28 18:35:10 lum Exp $ */
/* This file is in the public domain. */
@@ -19,6 +19,7 @@
#include <ctype.h>
#include <signal.h>
#include <fcntl.h>
+#include <err.h>
#include <errno.h>
#include <libgen.h>
#include <stdarg.h>
@@ -44,6 +45,7 @@ static int d_backpage(int, int);
static int d_forwline(int, int);
static int d_backline(int, int);
static void reaper(int);
+static struct buffer *refreshbuffer(struct buffer *);
extern struct keymap_s helpmap, cXmap, metamap;
@@ -423,7 +425,8 @@ d_copy(int f, int n)
ret = (copy(frname, toname) >= 0) ? TRUE : FALSE;
if (ret != TRUE)
return (ret);
- bp = dired_(curbp->b_fname);
+ if ((bp = refreshbuffer(curbp)) == NULL)
+ return (FALSE);
return (showbuffer(bp, curwp, WFFULL | WFMODE));
}
@@ -456,7 +459,8 @@ d_rename(int f, int n)
ret = (rename(frname, toname) >= 0) ? TRUE : FALSE;
if (ret != TRUE)
return (ret);
- bp = dired_(curbp->b_fname);
+ if ((bp = refreshbuffer(curbp)) == NULL)
+ return (FALSE);
return (showbuffer(bp, curwp, WFFULL | WFMODE));
}
@@ -639,10 +643,33 @@ d_create_directory(int f, int n)
tocreate);
return (FALSE);
}
- bp = dired_(curbp->b_fname);
+ if ((bp = refreshbuffer(curbp)) == NULL)
+ return (FALSE);
return (showbuffer(bp, curwp, WFFULL | WFMODE));
}
+struct buffer *
+refreshbuffer(struct buffer *bp)
+{
+ char *tmp;
+
+ tmp = strdup(bp->b_fname);
+ if (tmp == NULL)
+ err(1, NULL);
+
+ killbuffer(bp);
+
+ /* dired_() uses findbuffer() to create new buffer */
+ if ((bp = dired_(tmp)) == NULL) {
+ free(tmp);
+ return (NULL);
+ }
+ free(tmp);
+ curbp = bp;
+
+ return (bp);
+}
+
static int
d_makename(struct line *lp, char *fn, size_t len)
{