Repository: spyder-ide/spyder

Issue:
Increase or make adjustable the maximum number of Recent Projects
###  Problem Description

The number of Recent Projects is hard coded to 10 as can be seen from file 
https://github.com/spyder-ide/spyder/blob/master/spyder/plugins/projects/plugin.py

    def add_to_recent(self, project):
        """
        Add an entry to recent projetcs
        We only maintain the list of the 10 most recent projects
        """
        if project not in self.recent_projects:
            self.recent_projects.insert(0, project)
            self.recent_projects = self.recent_projects[:10]


### What steps reproduce the problem?

1.  Discussed on Stackoverflow 
https://stackoverflow.com/questions/58748718/is-there-a-way-to-increase-the-maximum-number-of-recent-projects-in-spyder

### What is the expected output? What do you see instead?
It would be nice to increase to 50 or make adjustable the maximum number of Recent Projects.


## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version: 3.3.6



Discussion:
@juanis2112, the idea here is to add a new entry to the "Recent projects" submenu

![Selección_001](https://user-images.githubusercontent.com/365293/68601490-6aa1e880-0472-11ea-9892-8b97ebd21fd1.png)

called "Maximum number of recent projects...", that works in the same way as "Maximum number of recent files..." in the "Open recent" submenu

![Selección_002](https://user-images.githubusercontent.com/365293/68601635-b3f23800-0472-11ea-97d7-a7c719e9444f.png)


Resolving patch:
diff --git a/spyder/config/main.py b/spyder/config/main.py
--- a/spyder/config/main.py
+++ b/spyder/config/main.py
@@ -270,6 +270,7 @@
               'name_filters': NAME_FILTERS,
               'show_all': True,
               'show_hscrollbar': True,
+              'max_recent_projects': 10,
               'visible_if_project_open': True
               }),
             ('explorer',
@@ -584,6 +585,7 @@
             'current_project_path',
             'expanded_state',
             'recent_projects',
+            'max_recent_projects',
             'scrollbar_position',
           ]
          ),
diff --git a/spyder/plugins/projects/plugin.py b/spyder/plugins/projects/plugin.py
--- a/spyder/plugins/projects/plugin.py
+++ b/spyder/plugins/projects/plugin.py
@@ -19,7 +19,7 @@
 # Third party imports
 from qtpy.compat import getexistingdirectory
 from qtpy.QtCore import Signal, Slot
-from qtpy.QtWidgets import QMenu, QMessageBox, QVBoxLayout
+from qtpy.QtWidgets import QInputDialog, QMenu, QMessageBox, QVBoxLayout
 
 # Local imports
 from spyder.config.base import _, get_home_dir
@@ -102,11 +102,17 @@ def get_plugin_actions(self):
         self.delete_project_action = create_action(self,
                                     _("Delete Project"),
                                     triggered=self.delete_project)
-        self.clear_recent_projects_action =\
-            create_action(self, _("Clear this list"),
-                          triggered=self.clear_recent_projects)
+        self.clear_recent_projects_action = create_action(
+            self,
+            _("Clear this list"),
+            triggered=self.clear_recent_projects)
         self.recent_project_menu = QMenu(_("Recent Projects"), self)
 
+        self.max_recent_action = create_action(
+            self,
+            _("Maximum number of recent projects..."),
+            triggered=self.change_max_recent_projects)
+
         if self.main is not None:
             self.main.projects_menu_actions += [self.new_project_action,
                                                 MENU_SEPARATOR,
@@ -239,9 +245,11 @@ def setup_menu_actions(self):
             self.recent_projects_actions += [
                 None,
                 self.clear_recent_projects_action,
+                self.max_recent_action
             ]
         else:
-            self.recent_projects_actions = [self.clear_recent_projects_action]
+            self.recent_projects_actions = [self.clear_recent_projects_action,
+                                            self.max_recent_action]
         add_actions(self.recent_project_menu, self.recent_projects_actions)
         self.update_project_actions()
 
@@ -385,6 +393,20 @@ def clear_recent_projects(self):
         self.recent_projects = []
         self.setup_menu_actions()
 
+    def change_max_recent_projects(self):
+        """Change max recent projects entries."""
+
+        mrf, valid = QInputDialog.getInt(
+            self,
+            _('Projects'),
+            _('Maximum number of recent projects'),
+            self.get_option('max_recent_projects'),
+            1,
+            35)
+
+        if valid:
+            self.set_option('max_recent_projects', mrf)
+
     def get_active_project(self):
         """Get the active project"""
         return self.current_active_project
@@ -506,7 +528,8 @@ def add_to_recent(self, project):
         """
         if project not in self.recent_projects:
             self.recent_projects.insert(0, project)
-            self.recent_projects = self.recent_projects[:10]
+        if len(self.recent_projects) > self.get_option('max_recent_projects'):
+            self.recent_projects.pop(-1)
 
     def register_lsp_server_settings(self, settings):
         """Enable LSP workspace functions."""


Test patch:
diff --git a/spyder/plugins/projects/tests/test_plugin.py b/spyder/plugins/projects/tests/test_plugin.py
--- a/spyder/plugins/projects/tests/test_plugin.py
+++ b/spyder/plugins/projects/tests/test_plugin.py
@@ -282,7 +282,7 @@ def test_recent_projects_menu_action(projects, tmpdir):
     projects.open_project(path=path1)
     projects.open_project(path=path2)
     assert (len(projects.recent_projects_actions) ==
-            recent_projects_len + 3 + 2)
+            recent_projects_len + 3 + 3)
     assert projects.get_active_project().root_path == path2
 
     # Trigger project1 in the list of Recent Projects actions.