hi,
If you find-file (C-x C-f) and select a directory instead of a file,
mg will eventually call dired but due to the current location of the
call to dired in mg, find-file calls showbuffer() multiple times.
Apart from being wastefull, doing this results in the cursor ending up
on the wrong line of the dired buffer, it lands on line 1 instead of
the line after "..".
This diff checks to see if the requested path is a directory as soon
as find-file is called, and if so calls dired. This removes the
problems mention previously.
Comments/ok?
mark
Index: file.c
===================================================================
RCS file: /cvs/src/usr.bin/mg/file.c,v
retrieving revision 1.97
diff -u -p -u -p -r1.97 file.c
--- file.c 25 Mar 2015 12:25:36 -0000 1.97
+++ file.c 25 Sep 2015 10:40:57 -0000
@@ -45,10 +45,10 @@ fileinsert(int f, int n)
}
/*
- * Select a file for editing. Look around to see if you can find the file
- * in another buffer; if you can find it, just switch to the buffer. If
- * you cannot find the file, create a new buffer, read in the text, and
- * switch to the new buffer.
+ * Select a file for editing. If the file is a directory, invoke dired.
+ * Otherwise look around to see if you can find the file in another buffer;
+ * if you can find it, just switch to the buffer. If you cannot find the
+ * file, create a new buffer, read in the text, and switch to the new buffer.
*/
/* ARGSUSED */
int
@@ -66,6 +66,12 @@ filevisit(int f, int n)
return (ABORT);
else if (bufp[0] == '\0')
return (FALSE);
+ if (fisdir(fname) == TRUE) {
+ if ((bp = dired_(bufp)) == FALSE)
+ return (FALSE);
+ curbp = bp;
+ return (showbuffer(bp, curwp, WFFULL | WFMODE));
+ }
adjf = adjustname(fname, TRUE);
if (adjf == NULL)
return (FALSE);