qemacs-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemacs-commit] qemacs shell.c latex-mode.c


From: Charlie Gordon
Subject: [Qemacs-commit] qemacs shell.c latex-mode.c
Date: Tue, 24 Dec 2013 16:12:48 +0000

CVSROOT:        /sources/qemacs
Module name:    qemacs
Changes by:     Charlie Gordon <chqrlie>        13/12/24 16:12:48

Modified files:
        .              : shell.c latex-mode.c 

Log message:
        use shell commands for all subprocesses

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/qemacs/shell.c?cvsroot=qemacs&r1=1.68&r2=1.69
http://cvs.savannah.gnu.org/viewcvs/qemacs/latex-mode.c?cvsroot=qemacs&r1=1.31&r2=1.32

Patches:
Index: shell.c
===================================================================
RCS file: /sources/qemacs/qemacs/shell.c,v
retrieving revision 1.68
retrieving revision 1.69
diff -u -b -r1.68 -r1.69
--- shell.c     23 Dec 2013 23:33:34 -0000      1.68
+++ shell.c     24 Dec 2013 16:12:48 -0000      1.69
@@ -192,8 +192,9 @@
         /* child process */
 
         /* detach controlling terminal */
+#ifndef CONFIG_DARWIN
         setsid();
-
+#endif
         /* close all files */
         nb_fds = getdtablesize();
         for (i = 0; i < nb_fds; i++)
@@ -212,7 +213,9 @@
             dup(0);
             dup(0);
         }
-
+#ifdef CONFIG_DARWIN
+        setsid();
+#endif
         setenv("TERM", "xterm", 1);
         unsetenv("PAGER");
         //setenv("QELEVEL", "1", 1);
@@ -1455,11 +1458,22 @@
     return b;
 }
 
+static const char *get_shell(void)
+{
+    const char *shell_path;
+
+    /* find shell name */
+    shell_path = getenv("SHELL");
+    if (!shell_path)
+        shell_path = "/bin/sh";
+
+    return shell_path;
+}
+
 static void do_shell(EditState *s, int force)
 {
     EditBuffer *b;
-    const char *argv[3];
-    const char *shell_path;
+    const char *argv[2];
 
     /* CG: Should prompt for buffer name if arg:
      * find a syntax for optional string argument w/ prompt
@@ -1470,15 +1484,10 @@
             return;
     }
 
-    /* find shell name */
-    shell_path = getenv("SHELL");
-    if (!shell_path)
-        shell_path = "/bin/sh";
-
     /* create new buffer */
-    argv[0] = shell_path;
+    argv[0] = get_shell();
     argv[1] = NULL;
-    b = new_shell_buffer(NULL, "*shell*", shell_path, argv, 1);
+    b = new_shell_buffer(NULL, "*shell*", argv[0], argv, 1);
     if (!b)
         return;
 
@@ -1491,23 +1500,24 @@
 
 static void do_man(EditState *s, const char *arg)
 {
-    const char *man_path;
-    const char *argv[3];
+    const char *argv[4];
     char bufname[32];
+    char cmd[128];
     EditBuffer *b;
     
     /* Assume standard man command */
-    man_path = "/usr/bin/man";
+    snprintf(cmd, sizeof(cmd), "man %s", arg);
 
     snprintf(bufname, sizeof(bufname), "*Man %s*", arg);
     if (try_show_buffer(s, bufname))
         return;
 
     /* create new buffer */
-    argv[0] = man_path;
-    argv[1] = arg;
-    argv[2] = NULL;
-    b = new_shell_buffer(NULL, bufname, man_path, argv, 2);
+    argv[0] = get_shell();
+    argv[1] = "-c";
+    argv[2] = cmd;
+    argv[3] = NULL;
+    b = new_shell_buffer(NULL, bufname, argv[0], argv, 2);
     if (!b)
         return;
 
@@ -1668,11 +1678,11 @@
         cmd = "make";
 
     /* create new buffer */
-    argv[0] = "/bin/sh";
+    argv[0] = get_shell();
     argv[1] = "-c";
-    argv[2] = (char *)cmd;
+    argv[2] = cmd;
     argv[3] = NULL;
-    b = new_shell_buffer(NULL, "*compilation*", "/bin/sh", argv, 3);
+    b = new_shell_buffer(NULL, "*compilation*", argv[0], argv, 3);
     if (!b)
         return;
 

Index: latex-mode.c
===================================================================
RCS file: /sources/qemacs/qemacs/latex-mode.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- latex-mode.c        23 Nov 2013 19:11:14 -0000      1.31
+++ latex-mode.c        24 Dec 2013 16:12:48 -0000      1.32
@@ -261,7 +261,7 @@
         }
 
         /* create new buffer */
-        b = new_shell_buffer(NULL, "*LaTeX output*", "/bin/sh", argv, 0);
+        b = new_shell_buffer(NULL, "*LaTeX output*", argv[0], argv, 0);
         if (b) {
             /* XXX: try to split window if necessary */
             switch_to_buffer(func->es, b);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]