By shuffling find-alternate-file around we have
dired-find-alternate-file as well. ok?

-lum

Index: def.h
===================================================================
RCS file: /cvs/src/usr.bin/mg/def.h,v
retrieving revision 1.153
diff -u -p -u -p -r1.153 def.h
--- def.h       29 Dec 2015 19:44:32 -0000      1.153
+++ def.h       30 Dec 2015 13:20:35 -0000
@@ -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);
Index: dired.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/dired.c,v
retrieving revision 1.81
diff -u -p -u -p -r1.81 dired.c
--- dired.c     11 Dec 2015 20:21:23 -0000      1.81
+++ dired.c     30 Dec 2015 13:20:35 -0000
@@ -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
@@ -838,6 +841,17 @@ d_backline (int f, int n)
 {
        backline(f | FFRAND, 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));
 }
 
 /*
Index: file.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/file.c,v
retrieving revision 1.99
diff -u -p -u -p -r1.99 file.c
--- file.c      29 Oct 2015 19:46:47 -0000      1.99
+++ file.c      30 Dec 2015 13:20:35 -0000
@@ -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, *fn;
 
        if (getbufcwd(fname, sizeof(fname)) != TRUE)
                fname[0] = '\0';
@@ -107,11 +105,23 @@ filevisitalt(int f, int n)
        else if (bufp[0] == '\0')
                return (FALSE);
 
+       fn = fname;
+
+       return (do_filevisitalt(fn));
+}
+
+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)
Index: mg.1
===================================================================
RCS file: /cvs/src/usr.bin/mg/mg.1,v
retrieving revision 1.99
diff -u -p -u -p -r1.99 mg.1
--- mg.1        29 Dec 2015 19:44:32 -0000      1.99
+++ mg.1        30 Dec 2015 13:20:35 -0000
@@ -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
 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.
 .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.

Reply via email to