static void do_compile(EditState *e, const char *cmd) { const char *argv[4]; EditBuffer *b; /* if the buffer already exists, kill it */ b = eb_find("*compilation*"); if (b) { /* XXX: e should not become invalid */ b->modified = 0; do_kill_buffer(e, "*compilation*"); } error_offset = -1; last_line_num = -1; /* create new buffer */ argv[0] = "/bin/sh"; argv[1] = "-c"; argv[2] = (char *)cmd; argv[3] = NULL; b = new_shell_buffer("*compilation*", "/bin/sh", argv, 0); if (!b) return; /* XXX: try to split window if necessary */ switch_to_buffer(e, b); }
static void latex_cmd_run(void *opaque, char *cmd) { struct latex_function *func = (struct latex_function *)opaque; char *argv[4], cwd[1024]; char *wd, *p; int len; if(cmd == 0) { put_status(func->es, "aborted"); return; } argv[0] = "/bin/sh"; argv[1] = "-c"; argv[2] = cmd; argv[3] = NULL; getcwd(cwd, sizeof(cwd)); /* get the directory of the open file and change into it */ p = strrchr(func->es->b->filename, '/'); if(p == func->es->b->filename) p++; len = p - func->es->b->filename + 1; wd = (char *)malloc(len); pstrcpy(wd, len, func->es->b->filename); chdir(wd); free(wd); if(func->output_to_buffer) { /* if the buffer already exists, kill it */ EditBuffer *b = eb_find("*LaTeX output*"); if (b) { /* XXX: e should not become invalid */ b->modified = 0; do_kill_buffer(func->es, "*LaTeX output*"); } /* create new buffer */ b = new_shell_buffer("*LaTeX output*", "/bin/sh", argv, 0); if (b) /* XXX: try to split window if necessary */ switch_to_buffer(func->es, b); } else { int pid = fork(); if (pid == 0) { /* child process */ setsid(); execv("/bin/sh", (char *const*)argv); exit(1); } } chdir(cwd); }
static void bufed_kill_item(void *opaque, StringItem *item) { EditState *s = opaque; do_kill_buffer(s, item->str); }