diff --git a/pd/src/m_glob.c b/pd/src/m_glob.c
index b3ed14c9fe2315bc46b184112ffadfe20bfd95c1..3efde149b1e44e49cf33de51ab766602559cd4a5 100644
--- a/pd/src/m_glob.c
+++ b/pd/src/m_glob.c
@@ -31,6 +31,7 @@ void glob_midi_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv);
 void glob_midi_setapi(t_pd *dummy, t_floatarg f);
 void glob_start_path_dialog(t_pd *dummy, t_floatarg flongform);
 void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv);
+void glob_addtopath(t_pd *dummy, t_symbol *path, t_float saveit);
 void glob_start_startup_dialog(t_pd *dummy, t_floatarg flongform);
 void glob_startup_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv);
 void glob_ping(t_pd *dummy);
@@ -168,6 +169,8 @@ void glob_init(void)
         gensym("start-path-dialog"), 0);
     class_addmethod(glob_pdobject, (t_method)glob_path_dialog,
         gensym("path-dialog"), A_GIMME, 0);
+    class_addmethod(glob_pdobject, (t_method)glob_addtopath,
+        gensym("add-to-path"), A_SYMBOL, A_DEFFLOAT, 0);
     class_addmethod(glob_pdobject, (t_method)glob_start_startup_dialog,
         gensym("start-startup-dialog"), 0);
     class_addmethod(glob_pdobject, (t_method)glob_startup_dialog,
diff --git a/pd/src/s_path.c b/pd/src/s_path.c
index 321757a5b61c6cc40092e49811066e5e65d08c0d..e7ac2b1ecb8c18937772e7c99b408647333cc252 100644
--- a/pd/src/s_path.c
+++ b/pd/src/s_path.c
@@ -802,6 +802,22 @@ void glob_path_dialog(t_pd *dummy, t_symbol *s, int argc, t_atom *argv)
     }
 }
 
+    /* AG 20190801: add one item to search path (backported from
+       vanilla rev. c917dd19, to make GEM happy). */
+void glob_addtopath(t_pd *dummy, t_symbol *path, t_float saveit)
+{
+  t_symbol *s = sys_decodedialog(path);
+  if (*s->s_name)
+  {
+    sys_searchpath = namelist_append_files(sys_searchpath, s->s_name);
+    if (saveit) {
+      /* AG: We just ignore this flag for now, later maybe save the
+         preferences here. GEM doesn't need this, and we don't use
+         Deken, so we can do without this. */
+    }
+  }
+}
+
     /* start a startup dialog window */
 void glob_start_startup_dialog(t_pd *dummy)
 {