diff -urNad nedit-5.6~cvs20081118~/source/menu.c nedit-5.6~cvs20081118/source/menu.c
--- nedit-5.6~cvs20081118~/source/menu.c	2014-02-02 14:59:38.000000000 +1100
+++ nedit-5.6~cvs20081118/source/menu.c	2020-01-06 15:33:34.581907181 +1100
@@ -102,6 +102,9 @@
 
 extern void _XmDismissTearOff(Widget, XtPointer, XtPointer);
 
+#ifdef SWITCH_DOCUMENTS_PATCH
+void initialiseSwitchDocumentsListWrapper();
+#endif
 static void doActionCB(Widget w, XtPointer clientData, XtPointer callData);
 static void doTabActionCB(Widget w, XtPointer clientData, XtPointer callData);
 static void pasteColCB(Widget w, XtPointer clientData, XtPointer callData); 
@@ -317,6 +320,16 @@
 	Cardinal *nArgs);
 static void lastDocumentAP(Widget w, XEvent *event, String *args,
 	Cardinal *nArgs);
+#ifdef SWITCH_DOCUMENTS_PATCH	
+static void switchDocumentsAP(Widget w, XEvent *event, String *args,
+	Cardinal *nArgs);
+static void switchDocumentsReverseAP(Widget w, XEvent *event, String *args,
+	Cardinal *nArgs);
+static void switchDocumentsEndAP(Widget w, XEvent *event, String *args,
+	Cardinal *nArgs);
+static void switchDocumentsNullAP(Widget w, XEvent *event, String *args,
+	Cardinal *nArgs);			
+#endif		
 static void closePaneAP(Widget w, XEvent *event, String *args, Cardinal *nArgs);
 static void capitalizeAP(Widget w, XEvent *event, String *args,
 	Cardinal *nArgs);
@@ -529,6 +542,12 @@
     {"next_document", nextDocumentAP},
     {"previous_document", prevDocumentAP},
     {"last_document", lastDocumentAP},
+#ifdef SWITCH_DOCUMENTS_PATCH    
+    {"switch_documents", switchDocumentsAP},
+    {"switch_documents_reverse", switchDocumentsReverseAP},
+    {"switch_documents_end", switchDocumentsEndAP},
+    {"switch_documents_null", switchDocumentsNullAP},        
+#endif    
     {"uppercase", capitalizeAP},
     {"lowercase", lowercaseAP},
     {"fill-paragraph", fillAP},
@@ -593,6 +612,13 @@
 static WindowInfo *ShortMenuWindow;
 #endif
 
+#ifdef SWITCH_DOCUMENTS_PATCH
+void initialiseSwitchDocumentsListWrapper()
+{
+    initialiseSwitchDocumentsList();
+}
+#endif
+
 void HidePointerOnKeyedEvent(Widget w, XEvent *event)
 {
     if (event && (event->type == KeyPress || event->type == KeyRelease)) {
@@ -705,7 +731,7 @@
     createMenuItem(menuPane, "print", "Print...", 'P', doActionCB, "print",
     	    SHORT);
     window->printSelItem = createMenuItem(menuPane, "printSelection",
-    	    "Print Selection...", 'l', doActionCB, "print_selection",
+    	    "Print Selection...", 't', doActionCB, "print_selection",
     	    SHORT);
     XtSetSensitive(window->printSelItem, window->wasSelected);
     createMenuSeparator(menuPane, "sep4", SHORT);
@@ -3549,6 +3575,32 @@
     LastDocument(WidgetToWindow(w));    
 }
 
+#ifdef SWITCH_DOCUMENTS_PATCH
+static void switchDocumentsAP(Widget w, XEvent *event, String *args,
+	Cardinal *nArgs)
+{    
+    switchDocuments(WidgetToWindow(w), SWITCH_DOCUMENTS_PATCH_DIRECTION_NORMAL);    
+}
+
+static void switchDocumentsReverseAP(Widget w, XEvent *event, String *args,
+	Cardinal *nArgs)
+{    
+    switchDocuments(WidgetToWindow(w), SWITCH_DOCUMENTS_PATCH_DIRECTION_REVERSE);    
+}
+
+static void switchDocumentsEndAP(Widget w, XEvent *event, String *args,
+	Cardinal *nArgs)
+{    
+    switchDocumentsEnd(WidgetToWindow(w));    
+}
+
+static void switchDocumentsNullAP(Widget w, XEvent *event, String *args,
+	Cardinal *nArgs)
+{    
+    
+}
+#endif
+
 static void capitalizeAP(Widget w, XEvent *event, String *args, Cardinal *nArgs)
 {
     WindowInfo *window = WidgetToWindow(w);
diff -urNad nedit-5.6~cvs20081118~/source/nedit.c nedit-5.6~cvs20081118/source/nedit.c
--- nedit-5.6~cvs20081118~/source/nedit.c	2014-02-02 14:59:38.000000000 +1100
+++ nedit-5.6~cvs20081118/source/nedit.c	2014-02-02 14:01:14.000000000 +1100
@@ -411,6 +411,10 @@
     /* Save the command which was used to invoke nedit for restart command */
     ArgV0 = argv[0];
 
+    #ifdef SWITCH_DOCUMENTS_PATCH
+    initialiseSwitchDocumentsListWrapper();
+    #endif
+
     /* Set locale for C library, X, and Motif input functions. 
        Reverts to "C" if requested locale not available. */
     XtSetLanguageProc(NULL, neditLanguageProc, NULL);
diff -urNad nedit-5.6~cvs20081118~/source/nedit.h nedit-5.6~cvs20081118/source/nedit.h
--- nedit-5.6~cvs20081118~/source/nedit.h	2014-02-02 14:59:38.000000000 +1100
+++ nedit-5.6~cvs20081118/source/nedit.h	2014-02-02 14:01:14.000000000 +1100
@@ -45,6 +45,8 @@
 #define NEDIT_VERSION           5
 #define NEDIT_REVISION          5
 
+#define SWITCH_DOCUMENTS_PATCH
+
 /* Some default colors */
 #define NEDIT_DEFAULT_FG        "black"
 #define NEDIT_DEFAULT_TEXT_BG   "rgb:e5/e5/e5"
diff -urNad nedit-5.6~cvs20081118~/source/window.c nedit-5.6~cvs20081118/source/window.c
--- nedit-5.6~cvs20081118~/source/window.c	2014-02-02 14:59:38.000000000 +1100
+++ nedit-5.6~cvs20081118/source/window.c	2020-01-06 15:41:02.921900938 +1100
@@ -193,6 +193,149 @@
 
 static WindowInfo *inFocusDocument = NULL;  	/* where we are now */
 static WindowInfo *lastFocusDocument = NULL;	    	/* where we came from */
+
+#ifdef SWITCH_DOCUMENTS_PATCH
+
+typedef struct SwitchDocumentsListNode
+{
+    int windowIDdebug;
+    WindowInfo * focusDocument;
+    struct SwitchDocumentsListNode* next;
+    struct SwitchDocumentsListNode* previous;
+} SwitchDocumentsList;
+
+static SwitchDocumentsList* firstNodeInSwitchDocumentsList;
+static SwitchDocumentsList* activeNodeInSwitchDocumentsList;
+int switchDocumentsListTraverseDisableMarkActiveDocument;
+struct timeval switchDocumentsClockLastSave;
+int switchingDocumentsAtPresent;
+
+struct timeval getTimeNow()
+{
+    struct timeval timenow;
+    gettimeofday(&timenow, NULL);
+    return timenow;
+}
+
+void printWindowList()
+{
+    printf("*****printWindowList:******\n");
+    printf("firstNodeInSwitchDocumentsList = %d\n", firstNodeInSwitchDocumentsList->windowIDdebug);
+    printf("activeNodeInSwitchDocumentsList = %d\n", activeNodeInSwitchDocumentsList->windowIDdebug);
+    SwitchDocumentsList* currentNode = firstNodeInSwitchDocumentsList;
+    WindowInfo *win;   
+     
+    while(currentNode->next != NULL)
+    {
+    	printf("\tcurrentNode = %d, currentNode pointer = %d\n", currentNode->windowIDdebug, currentNode->focusDocument);
+    	currentNode = currentNode->next;
+    }
+}
+
+void initialiseSwitchDocumentsList()
+{
+    switchDocumentsClockLastSave = getTimeNow();
+    firstNodeInSwitchDocumentsList = malloc(sizeof(SwitchDocumentsList));
+    firstNodeInSwitchDocumentsList->windowIDdebug = 0;
+    firstNodeInSwitchDocumentsList->focusDocument = NULL;
+    firstNodeInSwitchDocumentsList->next = NULL;
+    firstNodeInSwitchDocumentsList->previous = NULL;
+    activeNodeInSwitchDocumentsList = firstNodeInSwitchDocumentsList;
+    switchDocumentsListTraverseDisableMarkActiveDocument = 0;
+    switchingDocumentsAtPresent = 0;
+}
+
+SwitchDocumentsList* switchDocumentsGetLastNodeInList()
+{
+    SwitchDocumentsList* currentNode = firstNodeInSwitchDocumentsList;
+    SwitchDocumentsList* lastNodeInList = currentNode;
+    while(currentNode->next != NULL)
+    {
+    	lastNodeInList = currentNode;
+    	currentNode = currentNode->next;
+    }
+    return lastNodeInList;
+}
+		    
+SwitchDocumentsList* switchDocumentsListRemoveNode(SwitchDocumentsList* nodeToRemove)
+{   
+    if(nodeToRemove->next != NULL)
+    {
+	if(nodeToRemove->previous == NULL)
+	{/*nodeToRemove is first node in list*/
+
+    	    nodeToRemove->next->previous = NULL;
+	    firstNodeInSwitchDocumentsList = nodeToRemove->next;
+
+	}
+	else
+	{/*nodeToRemove is not first node in list*/
+	    nodeToRemove->previous->next = nodeToRemove->next;
+	    nodeToRemove->next->previous = nodeToRemove->previous;
+	}
+	free(nodeToRemove);
+    }
+    else
+    {
+	printf("switchDocumentsListRemoveNode() error: removing dummy node is impossible: (nodeToRemove->next == NULL)\n");
+	exit(0);
+    }   
+
+    SwitchDocumentsList* lastNodeInList = switchDocumentsGetLastNodeInList();
+        
+    return lastNodeInList;     /*update activeNodeInSwitchDocumentsList (restore to last document in list)*/
+}
+
+SwitchDocumentsList* switchDocumentsListRemove(WindowInfo * focusDocument)
+{
+    SwitchDocumentsList* currentNode = firstNodeInSwitchDocumentsList;
+    SwitchDocumentsList* nodeToRemove = NULL;
+    int foundNodeToRemove = 0;
+    while(currentNode->next != NULL)
+    { 
+    	if(currentNode->focusDocument == focusDocument)
+	{
+	    /*found node to remove*/
+	    nodeToRemove = currentNode;
+	    foundNodeToRemove = 1;
+	}
+    	currentNode = currentNode->next;
+    }
+    SwitchDocumentsList* lastNodeInList = currentNode;
+    if(foundNodeToRemove)
+    {
+    	 lastNodeInList = switchDocumentsListRemoveNode(nodeToRemove);
+    }
+    else
+    {
+    }
+    return lastNodeInList;
+}
+
+SwitchDocumentsList* switchDocumentsListAdd(WindowInfo * focusDocument)
+{
+    switchDocumentsListRemove(focusDocument);	/*remove previous instance if existent*/
+      
+    SwitchDocumentsList* currentNode = firstNodeInSwitchDocumentsList;
+    int lastNewWindowIDdebug = 0;
+    while(currentNode->next != NULL)
+    {
+	lastNewWindowIDdebug = currentNode->windowIDdebug;
+    	currentNode = currentNode->next;
+    }
+    currentNode->windowIDdebug = lastNewWindowIDdebug+1;
+    currentNode->focusDocument = focusDocument;
+    SwitchDocumentsList* newNode = malloc(sizeof(SwitchDocumentsList));
+    newNode->focusDocument = NULL;
+    newNode->next = NULL;
+    newNode->previous = currentNode;
+    currentNode->next = newNode; 
+      
+    return currentNode;
+}
+
+#endif
+
 static int DoneWithMoveDocumentDialog;
 static int updateLineNumDisp(WindowInfo* window);
 static int updateGutterWidth(WindowInfo* window);
@@ -800,6 +943,10 @@
 	}
     }
     
+    #ifdef SWITCH_DOCUMENTS_PATCH
+    activeNodeInSwitchDocumentsList = switchDocumentsListAdd(window);  
+    #endif
+        
     return window;
 }
 
@@ -3785,7 +3932,7 @@
     
     if (window)
     	lastFocusDocument = window;
-	
+    	
     return prev;
 }
 
@@ -3799,6 +3946,18 @@
     if (window)
     	inFocusDocument = window;
 
+    #ifdef SWITCH_DOCUMENTS_PATCH
+    if(switchDocumentsListTraverseDisableMarkActiveDocument == 0)
+    {
+	if(switchingDocumentsAtPresent == 1)
+	{/*in strange case user is switching documents while creating a new window for example?*/
+    	    activeNodeInSwitchDocumentsList = switchDocumentsListAdd(activeNodeInSwitchDocumentsList->focusDocument);	
+	    switchingDocumentsAtPresent = 0; 
+	} 
+    	activeNodeInSwitchDocumentsList = switchDocumentsListAdd(inFocusDocument);
+    }   
+    #endif
+
     return prev;
 }
 
@@ -3863,6 +4022,70 @@
 	
 }
 
+#ifdef SWITCH_DOCUMENTS_PATCH
+
+void switchDocumentsEnd(WindowInfo *window)
+{
+	if(switchingDocumentsAtPresent == 1)
+	{
+    		activeNodeInSwitchDocumentsList = switchDocumentsListAdd(activeNodeInSwitchDocumentsList->focusDocument);
+		switchingDocumentsAtPresent = 0;
+	}
+}
+/*
+** Switch through last active windows
+*/
+void switchDocuments(WindowInfo *window, int direction)
+{
+    WindowInfo *win;
+
+    if((activeNodeInSwitchDocumentsList->previous != NULL) || (activeNodeInSwitchDocumentsList->next->next != NULL))
+    {
+	if(direction == SWITCH_DOCUMENTS_PATCH_DIRECTION_NORMAL)
+	{
+	    if(activeNodeInSwitchDocumentsList->previous != NULL)
+	    {
+		activeNodeInSwitchDocumentsList = activeNodeInSwitchDocumentsList->previous;
+	    }
+	    else
+	    {/*go around in circles...*/
+		activeNodeInSwitchDocumentsList = switchDocumentsGetLastNodeInList();
+	    }
+	}
+	else if(direction != SWITCH_DOCUMENTS_PATCH_DIRECTION_NORMAL)
+	{
+	    if(activeNodeInSwitchDocumentsList->next->next != NULL)
+	    {
+		activeNodeInSwitchDocumentsList = activeNodeInSwitchDocumentsList->next;
+	    }
+	    else
+	    {/*go around in circles...*/
+		activeNodeInSwitchDocumentsList = firstNodeInSwitchDocumentsList;
+	    }	
+	}
+    }
+
+    switchingDocumentsAtPresent = 1;
+        
+    for(win = WindowList; win; win=win->next)
+    	if (activeNodeInSwitchDocumentsList->focusDocument == win)
+	    break;
+    
+    if (!win)
+    	return;
+
+    switchDocumentsListTraverseDisableMarkActiveDocument = 1;
+
+    if (window->shell == win->shell)
+	RaiseDocument(win);
+    else
+    	RaiseDocumentWindow(win);
+
+    switchDocumentsListTraverseDisableMarkActiveDocument = 0;	
+}
+#endif
+
+ 
 /*
 ** make sure window is alive is kicking
 */
@@ -4059,6 +4282,10 @@
         return;
     }
 
+    #ifdef SWITCH_DOCUMENTS_PATCH
+    switchDocumentsListRemove(window);   
+    #endif
+
     XtDestroyWidget(window->splitPane);
 }
 
diff -urNad nedit-5.6~cvs20081118~/source/window.h nedit-5.6~cvs20081118/source/window.h
--- nedit-5.6~cvs20081118~/source/window.h	2014-02-02 14:59:38.000000000 +1100
+++ nedit-5.6~cvs20081118/source/window.h	2014-02-02 14:01:14.000000000 +1100
@@ -84,6 +84,12 @@
 void NextDocument(WindowInfo *window);
 void PreviousDocument(WindowInfo *window);
 void LastDocument(WindowInfo *window);
+#ifdef SWITCH_DOCUMENTS_PATCH
+#define SWITCH_DOCUMENTS_PATCH_DIRECTION_NORMAL (1)
+#define SWITCH_DOCUMENTS_PATCH_DIRECTION_REVERSE (2)
+void switchDocuments(WindowInfo *window, int direction);
+void switchDocumentsEnd(WindowInfo *window);
+#endif
 int NDocuments(WindowInfo *window);
 WindowInfo *MoveDocument(WindowInfo *toWindow, WindowInfo *window);
 WindowInfo *DetachDocument(WindowInfo *window);
