    Display the File->Open Previous menu as a tree.

    This is another TK Soh patch:

    http://sourceforge.net/tracker/index.php?func=detail&aid=714486&group_id=11005&atid=311005
	    [ 714486 ] prevfile menu in tree-view
	    nedit-prevfiles-v1_0.diff.gz 2003-04-03 01:41

diff -aur nedit_official nedit_mod
diff -aur nedit_official/source/menu.c nedit_mod/source/menu.c
--- nedit_official/source/menu.c	2008-01-04 23:11:03.000000000 +0100
+++ nedit_mod/source/menu.c	2008-01-14 18:03:08.000000000 +0100
@@ -670,6 +670,7 @@
     if (GetPrefMaxPrevOpenFiles() > 0) {
 	window->prevOpenMenuPane = createMenu(menuPane, "openPrevious",
     		"Open Previous", 'v', &window->prevOpenMenuItem, SHORT);
+	XtVaSetValues(window->prevOpenMenuPane, XmNadjustMargin, False, NULL);    
 	XtSetSensitive(window->prevOpenMenuItem, NPrevOpen != 0);
 	XtAddCallback(window->prevOpenMenuItem, XmNcascadingCallback,
     		(XtCallbackProc)prevOpenMenuCB, window);
@@ -4672,19 +4673,30 @@
 ** Update the Previously Opened Files menu of a single window to reflect the
 ** current state of the list as retrieved from FIXME.
 ** Thanks to Markus Schwarzenberg for the sorting part.
+**
+** Optionally, display the prev-open list in directory-tree format.
 */
 static void updatePrevOpenMenu(WindowInfo *window)
 {
+    char filename[MAXPATHLEN], menuFilename[MAXPATHLEN]; 
+    char pathname[MAXPATHLEN], prevPathname[MAXPATHLEN];
+    char buf[MAXPATHLEN];
+    int matchPos;
+    Dimension indentMargin;
+    XmFontList fontlist;
     Widget btn;
     WidgetList items;
     Cardinal nItems;
-    int n, index;
+    int index;
     XmString st1;
     char **prevOpenSorted;
 
     /*  Read history file to get entries written by other sessions.  */
     ReadNEditDB();
                 
+    /* Get font info for menus */
+    XtVaGetValues(window->prevOpenMenuItem, XmNfontList, &fontlist, NULL);
+
     /* Sort the previously opened file list if requested */
     prevOpenSorted = (char **)XtMalloc(NPrevOpen * sizeof(char*));
     memcpy(prevOpenSorted, PrevOpen, NPrevOpen * sizeof(char*));
@@ -4698,35 +4710,79 @@
        stick with this weird method of re-naming the items */
     XtVaGetValues(window->prevOpenMenuPane, XmNchildren, &items,
             XmNnumChildren, &nItems, NULL);
-    index = 0;
-    for (n=0; n<(int)nItems; n++) {
-        if (index >= NPrevOpen) {
-            /* unmanaging before destroying stops parent from displaying */
-            XtUnmanageChild(items[n]);
-            XtDestroyWidget(items[n]);          
-        } else {
-            XtVaSetValues(items[n], XmNlabelString,
-                    st1=XmStringCreateSimple(prevOpenSorted[index]), NULL);
-            XtRemoveAllCallbacks(items[n], XmNactivateCallback);
-            XtAddCallback(items[n], XmNactivateCallback,
-                    (XtCallbackProc)openPrevCB, prevOpenSorted[index]);
+    
+    /* in the begining ... */
+    prevPathname[0] = '\0';
+    
+    for (index=0; index<NPrevOpen; index++) {
+    	indentMargin = 0; 
+	if (GetPrefShowPrevOpenAsTree() &&
+	        !ParseFilename(prevOpenSorted[index], filename, pathname)) {
+    	    /* search for common sub-dir in prev and current paths */
+	    for (matchPos=strlen(pathname); matchPos>1; matchPos--)
+		if (pathname[matchPos] == '/' &&
+		        !strncmp(pathname, prevPathname, matchPos+1))
+		    break;
+
+    	    if (matchPos > 1) {
+		/* file is in sub-directory or same directory as
+		   previous file */
+		strcpy(buf,prevOpenSorted[index]);
+		buf[matchPos] = '\0';
+
+		/* calculate margin to be indented */
+		st1=XmStringCreateSimple(buf);
+    	    	indentMargin = XmStringWidth(fontlist, st1);
             XmStringFree(st1);
-            index++;
+
+    	    	/* create filepath without parent's dirname */
+		sprintf(menuFilename, "%s",
+		        &prevOpenSorted[index][matchPos]);
+    		st1=XmStringCreateSimple(menuFilename);
         }
+	    else {
+		/* file is in a totally different path */
+		st1=XmStringCreateSimple(prevOpenSorted[index]);
     }
     
-    /* Add new items for the remaining file names to the menu */
-    for (; index<NPrevOpen; index++) {
+	    strcpy(prevPathname, pathname);	    
+	}
+	else {
+	    /* full pathname mode */
+	    st1=XmStringCreateSimple(prevOpenSorted[index]);
+    	}
+	
+    	/* update/add filepath onto menu */
+	if ((int)nItems <= index) {
         btn = XtVaCreateManagedWidget("win", xmPushButtonWidgetClass,
                 window->prevOpenMenuPane, 
-                XmNlabelString, st1=XmStringCreateSimple(prevOpenSorted[index]),
+                XmNlabelString, st1,
                 XmNmarginHeight, 0,
+		XmNmarginLeft, indentMargin,
                 XmNuserData, TEMPORARY_MENU_ITEM, NULL);
         XtAddCallback(btn, XmNactivateCallback, (XtCallbackProc)openPrevCB, 
                 prevOpenSorted[index]);
+	}
+	else {
+            XtVaSetValues(items[index],
+	            XmNlabelString, st1,
+                    XmNmarginLeft, indentMargin, NULL);
+            XtRemoveAllCallbacks(items[index], XmNactivateCallback);
+
+            XtAddCallback(items[index], XmNactivateCallback,
+                    (XtCallbackProc)openPrevCB, prevOpenSorted[index]);
+	}
+
         XmStringFree(st1);
     }
                 
+    /* delete the extras (???) in the menu */
+    for (;  index<(int)nItems; index++) {
+        /* unmanaging before destroying stops parent from displaying */
+        XtUnmanageChild(items[index]);
+        XtDestroyWidget(items[index]);  
+    }
+                
     XtFree((char*)prevOpenSorted);
 }
 
diff -aur nedit_official/source/preferences.c nedit_mod/source/preferences.c
--- nedit_official/source/preferences.c	2008-01-13 13:04:35.000000000 +0100
+++ nedit_mod/source/preferences.c	2008-01-14 18:07:00.000000000 +0100
@@ -295,6 +295,7 @@
     int autoScroll;             /* w. to autoscroll near top/bottom of screen */
     int autoScrollVPadding;     /* how close to get before autoscrolling */
     int sortOpenPrevMenu;   	/* whether to sort the "Open Previous" menu */
+    int showPrevOpenAsTree;	/* show "Open Previous" menu in tree format */
     int appendLF;       /* Whether to append LF at the end of each file */
     int mapDelete;		/* whether to map delete to backspace */
     int stdOpenDialog;		/* w. to retain redundant text field in Open */
@@ -892,6 +893,8 @@
         &PrefData.appendLF, NULL, True},
     {"sortOpenPrevMenu", "SortOpenPrevMenu", PREF_BOOLEAN, "True",
     	&PrefData.sortOpenPrevMenu, NULL, True},
+    {"showPrevOpenAsTree", "ShowPrevOpenAsTree", PREF_BOOLEAN, "True",
+    	&PrefData.showPrevOpenAsTree, NULL, False},
     {"statisticsLine", "StatisticsLine", PREF_BOOLEAN, "False",
     	&PrefData.statsLine, NULL, True},
     {"iSearchLine", "ISearchLine", PREF_BOOLEAN, "False",
@@ -1958,6 +1961,16 @@
     return PrefData.sortOpenPrevMenu;
 }
 
+void SetPrefShowPrevOpenAsTree(int state)
+{
+    setIntPref(&PrefData.showPrevOpenAsTree, state);
+}
+
+int GetPrefShowPrevOpenAsTree(void)
+{
+    return PrefData.showPrevOpenAsTree;
+}
+
 char *GetPrefTagFile(void)
 {
     return PrefData.tagFile;
diff -aur nedit_official/source/preferences.h nedit_mod/source/preferences.h
--- nedit_official/source/preferences.h	2008-01-04 23:11:03.000000000 +0100
+++ nedit_mod/source/preferences.h	2008-01-14 18:06:53.000000000 +0100
@@ -126,6 +126,8 @@
 int GetPrefAppendLF(void);
 void SetPrefSortOpenPrevMenu(int state);
 int GetPrefSortOpenPrevMenu(void);
+void SetPrefShowPrevOpenAsTree(int state);
+int GetPrefShowPrevOpenAsTree(void);
 char *GetPrefTagFile(void);
 int GetPrefSmartTags(void);
 void SetPrefSmartTags(int state);
