Description: upstream: enhance: plugins: maple: HOME init-maple.mpl
 This patch allows the `tm_maple` interface to read a `init-maple.mpl`
 that is under the `TEXMACS_HOME_PATH` hierarchy. That is, if the file
 `$TEXMACS_HOME_PATH/plugins/maple/maple/init-maple.mpl` exists and is
 readable then it is `read` just after that
 `$TEXMACS_PATH/plugins/maple/maple/init-maple.mpl` is `read`.
 This allows end-users to customize their maple interface.
Origin: vendor, Debian
Forwarded: https://github.com/texmacs/texmacs/pull/93
Author: Jerome Benoit <calculus@rezozer.net>
Last-Update: 2024-08-09

--- a/plugins/maple/src.9/tm_maple_9.c
+++ b/plugins/maple/src.9/tm_maple_9.c
@@ -109,9 +109,12 @@
 * Launching maple
 ******************************************************************************/
 
+#define TMMPL_PI_MAPLEINIT_RELPATH "plugins/maple/maple/init-maple.mpl"
+
 int
 main (int argc, char *argv[]) {
   const char* tm_path=getenv("TEXMACS_PATH");
+  const char* tm_home_path=getenv("TEXMACS_HOME_PATH");
   char in [2148];
   char err[2048];
 	char tmmplinit [2048];
@@ -131,7 +134,7 @@
   (void) r;  /* silence unused-but-set-variable warning */
   (void) l;  /* silence unused-variable warning */
 
-	snprintf(tmmplinit,sizeof(tmmplinit),"%s/plugins/maple/maple/init-maple.mpl",tm_path);
+	snprintf(tmmplinit,sizeof(tmmplinit), "%s/" TMMPL_PI_MAPLEINIT_RELPATH ,tm_path);
 	if (access(tmmplinit,R_OK)) {
 		printf("Fatal error, unable to read `%s`\n",tmmplinit);
 		return( 1 );
@@ -156,6 +159,12 @@
 	snprintf(in,sizeof(in),"read(`%s`);",tmmplinit);
   r= EvalMapleStatement (kv, in);
 
+	snprintf(tmmplinit,sizeof(tmmplinit), "%s/" TMMPL_PI_MAPLEINIT_RELPATH ,tm_home_path);
+	if (!(access(tmmplinit,R_OK))) {
+		snprintf(in,sizeof(in),"read(`%s`);",tmmplinit);
+		r= EvalMapleStatement (kv, in);
+	}
+
   while (1) {
     next_input ();
     printf("\5");
@@ -174,7 +183,7 @@
       MapleHelp (kv, in+1, NULL, writeHelpChar, NULL, 80, NULL);
     else {
       if (in[strlen(in)-1] != ':')
-	strcat (in, ":tmresult:=\%:tmprint(tmresult):tmresult:");
+        strcat (in, ":tmresult:=\%:tmprint(tmresult):tmresult:");
       r = EvalMapleStatement (kv, in);
     }
   }
@@ -183,3 +192,5 @@
 
   return (0);
 }
+
+#undef TMMPL_PI_MAPLEINIT_RELPATH
