vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Here is a simple patch that aims to bring mg's behaviour closer to emacs. emacs dirname Will open `dirname' in a dired-buffer. This patch aims to do the same. Allas I got stuck. If one presses return you get the c-n effect instead of opening the file under the cursor. I don't really understand why actually. So if anyone thinks this is a useful feature and knows how to make it work properly, be my guest. Index: fileio.c ================================================== ================= RCS file: /cvs/src/usr.bin/mg/fileio.c,v retrieving revision 1.50 diff -u -p -u -p -w -r1.50 fileio.c --- fileio.c 14 Jun 2005 18:14:40 -0000 1.50 +++ fileio.c 9 Oct 2005 08:29:45 -0000 @@ -7,6 +7,11 @@ */ #include "def.h" +#ifndef NO_DIRED +#include <sys/wait.h> +#include "kbd.h" +#endif /* !NO_DIRED */ + #include <sys/types.h> #include <limits.h> #include <sys/stat.h> @@ -31,12 +36,31 @@ ffropen(const char *fn, BUFFER *bp) return (FIOFNF); return (FIOERR); } + + /* If `fn' is a directory open it with dired. */ + if ((stat(fn, &statbuf) == 0) && S_ISDIR(statbuf.st_mode)) { +#ifdef NO_DIRED + return (FIOERR); +#else + char *dirname; + + dirname = strdup(fn); + killbuffer(bp); + if ((bp = dired_(dirname)) == NULL) + return (FIOERR); + curbp = bp; + + return (showbuffer(bp, curwp, WFHARD | WFMODE)); +#endif /* NO_DIRED */ + } + if (bp && fstat(fileno(ffp), &statbuf) == 0) { /* set highorder bit to make sure this isn't all zero */ bp->b_fi.fi_mode = statbuf.st_mode | 0x8000; bp->b_fi.fi_uid = statbuf.st_uid; bp->b_fi.fi_gid = statbuf.st_gid; } + return (FIOSUC); } @@ -336,9 +360,6 @@ nohome: #endif #ifndef NO_DIRED -#include <sys/wait.h> -#include "kbd.h" - int copy(char *frname, char *toname) { # Han |