summaryrefslogtreecommitdiff
path: root/usr.bin/mg
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/mg')
-rw-r--r--usr.bin/mg/def.h3
-rw-r--r--usr.bin/mg/dired.c20
-rw-r--r--usr.bin/mg/file.c18
-rw-r--r--usr.bin/mg/mg.19
4 files changed, 39 insertions, 11 deletions
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index 21bc78cb4fd..51fd9ebdb12 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.153 2015/12/29 19:44:32 lum Exp $ */
+/* $OpenBSD: def.h,v 1.154 2016/01/02 10:39:19 lum Exp $ */
/* This file is in the public domain. */
@@ -377,6 +377,7 @@ int makebkfile(int, int);
int writeout(FILE **, struct buffer *, char *);
void upmodes(struct buffer *);
size_t xbasename(char *, const char *, size_t);
+int do_filevisitalt(char *);
/* line.c X */
struct line *lalloc(int);
diff --git a/usr.bin/mg/dired.c b/usr.bin/mg/dired.c
index 668bb325a2c..33cfc57a5fb 100644
--- a/usr.bin/mg/dired.c
+++ b/usr.bin/mg/dired.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dired.c,v 1.81 2015/12/11 20:21:23 mmcc Exp $ */
+/* $OpenBSD: dired.c,v 1.82 2016/01/02 10:39:19 lum Exp $ */
/* This file is in the public domain. */
@@ -51,6 +51,7 @@ static int d_forwline(int, int);
static int d_backline(int, int);
static int d_killbuffer_cmd(int, int);
static int d_refreshbuffer(int, int);
+static int d_filevisitalt(int, int);
static void reaper(int);
static struct buffer *refreshbuffer(struct buffer *);
static int createlist(struct buffer *);
@@ -120,7 +121,9 @@ static PF diredcz[] = {
d_create_directory /* + */
};
-static PF diredc[] = {
+static PF direda[] = {
+ d_filevisitalt, /* a */
+ rescan, /* b */
d_copy, /* c */
d_del, /* d */
d_findfile, /* e */
@@ -184,7 +187,7 @@ static struct KEYMAPE (7) diredmap = {
CCHR('Z'), '+', diredcz, (KEYMAP *) & metamap
},
{
- 'c', 'g', diredc, NULL
+ 'a', 'g', direda, NULL
},
{
'n', 'x', diredn, NULL
@@ -840,6 +843,17 @@ d_backline (int f, int n)
return (d_warpdot(curwp->w_dotp, &curwp->w_doto));
}
+int
+d_filevisitalt (int f, int n)
+{
+ char fname[NFILEN];
+
+ if (d_makename(curwp->w_dotp, fname, sizeof(fname)) == ABORT)
+ return (FALSE);
+
+ return(do_filevisitalt(fname));
+}
+
/*
* XXX dname needs to have enough place to store an additional '/'.
*/
diff --git a/usr.bin/mg/file.c b/usr.bin/mg/file.c
index 27b379de43c..6483b6b5c8f 100644
--- a/usr.bin/mg/file.c
+++ b/usr.bin/mg/file.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: file.c,v 1.99 2015/10/29 19:46:47 lum Exp $ */
+/* $OpenBSD: file.c,v 1.100 2016/01/02 10:39:19 lum Exp $ */
/* This file is in the public domain. */
@@ -94,9 +94,7 @@ filevisit(int f, int n)
int
filevisitalt(int f, int n)
{
- struct buffer *bp;
- char fname[NFILEN], *bufp, *adjf;
- int status;
+ char fname[NFILEN], *bufp;
if (getbufcwd(fname, sizeof(fname)) != TRUE)
fname[0] = '\0';
@@ -107,11 +105,21 @@ filevisitalt(int f, int n)
else if (bufp[0] == '\0')
return (FALSE);
+ return (do_filevisitalt(fname));
+}
+
+int
+do_filevisitalt(char *fn)
+{
+ struct buffer *bp;
+ int status;
+ char *adjf;
+
status = killbuffer(curbp);
if (status == ABORT || status == FALSE)
return (ABORT);
- adjf = adjustname(fname, TRUE);
+ adjf = adjustname(fn, TRUE);
if (adjf == NULL)
return (FALSE);
if (fisdir(adjf) == TRUE)
diff --git a/usr.bin/mg/mg.1 b/usr.bin/mg/mg.1
index 4edb05d0a5d..19fa0c3097c 100644
--- a/usr.bin/mg/mg.1
+++ b/usr.bin/mg/mg.1
@@ -1,7 +1,7 @@
-.\" $OpenBSD: mg.1,v 1.100 2015/12/30 16:53:17 lum Exp $
+.\" $OpenBSD: mg.1,v 1.101 2016/01/02 10:39:19 lum Exp $
.\" This file is in the public domain.
.\"
-.Dd $Mdocdate: December 30 2015 $
+.Dd $Mdocdate: January 2 2016 $
.Dt MG 1
.Os
.Sh NAME
@@ -952,6 +952,8 @@ dired-next-line
dired-shell-command
.It +
dired-create-directory
+.It a
+dired-find-alternate-file
.It c
dired-do-copy
.It d and C-d
@@ -988,6 +990,9 @@ Copy the file listed on the current line of the dired buffer.
Delete the files that have been flagged for deletion.
.It dired-do-rename
Rename the file listed on the current line of the dired buffer.
+.It dired-find-alternate-file
+Replace the current dired buffer with an alternate one as specified
+by the position of the cursor in the dired buffer.
.It dired-find-file
Open the file on the current line of the dired buffer.
If the cursor is on a directory it will be opened in dired mode.