コード例 #1
0
ファイル: archive.c プロジェクト: Ivan1234/qemacs
static int archive_buffer_load(EditBuffer *b, FILE *f)
{
    /* Launch subprocess to list archive contents */
    char cmd[1024];
    ArchiveType *atp;

    atp = find_archive_type(b->filename);
    if (atp) {
        eb_clear(b);
        eb_printf(b, "  Directory of %s archive %s\n",
                  atp->name, b->filename);
        snprintf(cmd, sizeof(cmd), atp->list_cmd, b->filename);
        new_shell_buffer(b, get_basename(b->filename), NULL, cmd,
                         SF_INFINITE | SF_BUFED_MODE);

        /* XXX: should check for archiver error */
        /* XXX: should delay BF_SAVELOG until buffer is fully loaded */
        b->flags |= BF_READONLY;

        return 0;
    } else {
        eb_printf(b, "Cannot find archiver\n");
        return -1;
    }
}
コード例 #2
0
ファイル: shell.c プロジェクト: kjk/qemacs
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);
}
コード例 #3
0
ファイル: latex-mode.c プロジェクト: deeice/Qemacs
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);
}
コード例 #4
0
ファイル: archive.c プロジェクト: Ivan1234/qemacs
static int wget_buffer_load(EditBuffer *b, FILE *f)
{
    /* Launch wget subprocess to retrieve contents */
    char cmd[1024];

    eb_clear(b);
    snprintf(cmd, sizeof(cmd), "wget -q -O - %s", b->filename);
    new_shell_buffer(b, get_basename(b->filename), NULL, cmd,
                     SF_INFINITE | SF_AUTO_CODING | SF_AUTO_MODE);
    /* XXX: should check for wget error */
    /* XXX: should delay BF_SAVELOG until buffer is fully loaded */
    b->flags |= BF_READONLY;

    return 0;
}
コード例 #5
0
ファイル: shell.c プロジェクト: kjk/qemacs
static void do_shell(EditState *s, int force)
{
    QEmacsState *qs = s->qe_state;
    EditState *e;
    EditBuffer *b;
    const char *argv[3];
    const char *shell_path;

    /* CG: Should prompt for buffer name if arg:
     * find a syntax for optional string argument w/ prompt
     */
    /* find shell buffer if any */
    if (!force || force == NO_ARG) {
        b = eb_find("*shell*");
        if (b) {
            e = edit_find(b);
            if (e)
                qs->active_window = e;
            else
                switch_to_buffer(s, b);
            return;
        }
    }

    /* find shell name */
    shell_path = getenv("SHELL");
    if (!shell_path)
        shell_path = "/bin/sh";

    /* create new buffer */
    argv[0] = shell_path;
    argv[1] = NULL;
    b = new_shell_buffer("*shell*", shell_path, argv, 1);
    if (!b)
        return;
    
    switch_to_buffer(s, b);
    do_set_mode(s, &shell_mode, NULL);

    put_status(s, "Press C-o to toggle between shell/edit mode");
    shell_launched = 1;
}
コード例 #6
0
ファイル: archive.c プロジェクト: Ivan1234/qemacs
static int compress_buffer_load(EditBuffer *b, FILE *f)
{
    /* Launch subprocess to expand compressed contents */
    char cmd[1024];
    CompressType *ctp;

    ctp = find_compress_type(b->filename);
    if (ctp) {
        eb_clear(b);
        snprintf(cmd, sizeof(cmd), ctp->load_cmd, b->filename);
        new_shell_buffer(b, get_basename(b->filename), NULL, cmd,
                         SF_INFINITE | SF_AUTO_CODING | SF_AUTO_MODE);
        /* XXX: should check for archiver error */
        /* XXX: should delay BF_SAVELOG until buffer is fully loaded */
        b->flags |= BF_READONLY;

        return 0;
    } else {
        eb_printf(b, "cannot find compressor\n");
        return -1;
    }
}
コード例 #7
0
ファイル: shell.c プロジェクト: deeice/Qemacs
static void do_shell(EditState *e)
{
    EditBuffer *b;
    char *argv[3];
    char *shell_path;

    /* find shell name */
    shell_path = getenv("SHELL");
    if (!shell_path)
        shell_path = "/bin/sh";

    /* create new buffer */
    argv[0] = shell_path;
    argv[1] = NULL;
    b = new_shell_buffer("*shell*", shell_path, argv, 1);
    if (!b)
        return;
    
    switch_to_buffer(e, b);
    do_set_mode(e, &shell_mode, NULL);

    put_status(e, "Press C-o to toggle between shell/edit mode");
    shell_launched = 1;
}