scripting issues:
- always pass universal argument as last argument - change do_compile_error() accordingly - pass universal argument to do_eval_expression()
This commit is contained in:
parent
436a0b2c60
commit
2aaabb719c
4 changed files with 43 additions and 42 deletions
69
parser.c
69
parser.c
|
|
@ -28,6 +28,16 @@
|
|||
* displayed as a popup upon start.
|
||||
*/
|
||||
|
||||
typedef struct QEmacsDataSource {
|
||||
const char *filename;
|
||||
FILE *f;
|
||||
EditBuffer *b;
|
||||
const char *str;
|
||||
int line_num;
|
||||
int pos, len;
|
||||
int offset, stop;
|
||||
} QEmacsDataSource;
|
||||
|
||||
static int expect_token(const char **pp, int tok)
|
||||
{
|
||||
if (skip_spaces(pp) == tok) {
|
||||
|
|
@ -43,14 +53,14 @@ static int qe_cfg_parse_string(EditState *s, const char **pp,
|
|||
char *dest, int size)
|
||||
{
|
||||
const char *p = *pp;
|
||||
int c, delim = *p++;
|
||||
int delim = *p++;
|
||||
int res = 0;
|
||||
int pos = 0;
|
||||
|
||||
for (;;) {
|
||||
/* encoding issues delibarately ignored */
|
||||
c = *p;
|
||||
if (c == '\0') {
|
||||
/* encoding issues deliberately ignored */
|
||||
int c = *p;
|
||||
if (c == '\n' || c == '\0') {
|
||||
put_status(s, "Unterminated string");
|
||||
res = -1;
|
||||
break;
|
||||
|
|
@ -72,6 +82,7 @@ static int qe_cfg_parse_string(EditState *s, const char **pp,
|
|||
break;
|
||||
}
|
||||
}
|
||||
/* XXX: silently truncate overlong string constants */
|
||||
if (pos < size - 1)
|
||||
dest[pos++] = c;
|
||||
}
|
||||
|
|
@ -81,16 +92,6 @@ static int qe_cfg_parse_string(EditState *s, const char **pp,
|
|||
return res;
|
||||
}
|
||||
|
||||
typedef struct QEmacsDataSource {
|
||||
const char *filename;
|
||||
FILE *f;
|
||||
EditBuffer *b;
|
||||
const char *str;
|
||||
int line_num;
|
||||
int pos, len;
|
||||
int offset, stop;
|
||||
} QEmacsDataSource;
|
||||
|
||||
static char *data_gets(QEmacsDataSource *ds, char *buf, int size)
|
||||
{
|
||||
if (ds->f) {
|
||||
|
|
@ -344,21 +345,7 @@ static int qe_parse_script(EditState *s, QEmacsDataSource *ds)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int parse_config_file(EditState *s, const char *filename)
|
||||
{
|
||||
QEmacsDataSource ds = { 0 };
|
||||
int res;
|
||||
|
||||
ds.filename = filename;
|
||||
ds.f = fopen(filename, "r");
|
||||
if (!ds.f)
|
||||
return -1;
|
||||
res = qe_parse_script(s, &ds);
|
||||
fclose(ds.f);
|
||||
return res;
|
||||
}
|
||||
|
||||
void do_eval_expression(EditState *s, const char *expression)
|
||||
void do_eval_expression(EditState *s, const char *expression, int argval)
|
||||
{
|
||||
QEmacsDataSource ds = { 0 };
|
||||
|
||||
|
|
@ -390,15 +377,28 @@ static int do_eval_buffer_region(EditState *s, int start, int stop)
|
|||
|
||||
void do_eval_region(EditState *s)
|
||||
{
|
||||
/* deactivate region hilite */
|
||||
s->region_style = 0;
|
||||
s->region_style = 0; /* deactivate region hilite */
|
||||
|
||||
do_eval_buffer_region(s, s->b->mark, s->offset);
|
||||
}
|
||||
|
||||
void do_eval_buffer(EditState *s)
|
||||
{
|
||||
do_eval_buffer_region(s, 0, -1);
|
||||
do_eval_buffer_region(s, 0, s->b->total_size);
|
||||
}
|
||||
|
||||
int parse_config_file(EditState *s, const char *filename)
|
||||
{
|
||||
QEmacsDataSource ds = { 0 };
|
||||
int res;
|
||||
|
||||
ds.filename = filename;
|
||||
ds.f = fopen(filename, "r");
|
||||
if (!ds.f)
|
||||
return -1;
|
||||
res = qe_parse_script(s, &ds);
|
||||
fclose(ds.f);
|
||||
return res;
|
||||
}
|
||||
|
||||
#ifndef CONFIG_TINY
|
||||
|
|
@ -424,7 +424,6 @@ void do_save_session(EditState *s, int popup)
|
|||
if (popup) {
|
||||
b->offset = 0;
|
||||
b->flags |= BF_READONLY;
|
||||
|
||||
show_popup(s, b, "QEmacs session");
|
||||
} else {
|
||||
eb_write_buffer(b, 0, b->total_size, ".qesession");
|
||||
|
|
@ -436,8 +435,8 @@ void do_save_session(EditState *s, int popup)
|
|||
static CmdDef parser_commands[] = {
|
||||
|
||||
CMD2( KEY_META(':'), KEY_NONE,
|
||||
"eval-expression", do_eval_expression, ESs,
|
||||
"s{Eval: }|expression|")
|
||||
"eval-expression", do_eval_expression, ESsi,
|
||||
"s{Eval: }|expression|ui")
|
||||
CMD0( KEY_NONE, KEY_NONE,
|
||||
"eval-region", do_eval_region)
|
||||
CMD0( KEY_NONE, KEY_NONE,
|
||||
|
|
|
|||
8
qe.c
8
qe.c
|
|
@ -3109,6 +3109,7 @@ void do_set_style(EditState *e, const char *stylestr,
|
|||
}
|
||||
break;
|
||||
}
|
||||
//s->qe_state->complete_refresh = 1;
|
||||
}
|
||||
|
||||
void do_define_color(EditState *e, const char *name, const char *value)
|
||||
|
|
@ -3162,6 +3163,7 @@ void do_set_window_style(EditState *s, const char *stylestr)
|
|||
void do_set_system_font(EditState *s, const char *qe_font_name,
|
||||
const char *system_fonts)
|
||||
{
|
||||
QEmacsState *qs = s->qe_state;
|
||||
int font_type;
|
||||
|
||||
font_type = css_get_enum(qe_font_name, "fixed,serif,sans");
|
||||
|
|
@ -3169,9 +3171,9 @@ void do_set_system_font(EditState *s, const char *qe_font_name,
|
|||
put_status(s, "Invalid qemacs font");
|
||||
return;
|
||||
}
|
||||
pstrcpy(s->qe_state->system_fonts[font_type],
|
||||
sizeof(s->qe_state->system_fonts[0]),
|
||||
pstrcpy(qs->system_fonts[font_type], sizeof(qs->system_fonts[0]),
|
||||
system_fonts);
|
||||
//qs->complete_refresh = 1;
|
||||
}
|
||||
|
||||
static void display_bol_bidir(DisplayState *ds, DirType base,
|
||||
|
|
@ -9099,7 +9101,7 @@ static void qe_init(void *opaque)
|
|||
|
||||
if (*arg == '+' && i < argc) {
|
||||
if (strequal(arg, "+eval")) {
|
||||
do_eval_expression(s, argv[i++]);
|
||||
do_eval_expression(s, argv[i++], NO_ARG);
|
||||
s = qs->active_window;
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
2
qe.h
2
qe.h
|
|
@ -2293,7 +2293,7 @@ void set_tty_charset(const char *name);
|
|||
/* parser.c */
|
||||
|
||||
int parse_config_file(EditState *s, const char *filename);
|
||||
void do_eval_expression(EditState *s, const char *expression);
|
||||
void do_eval_expression(EditState *s, const char *expression, int argval);
|
||||
void do_eval_region(EditState *s); /* should pass actual offsets */
|
||||
void do_eval_buffer(EditState *s);
|
||||
extern int use_session_file;
|
||||
|
|
|
|||
6
shell.c
6
shell.c
|
|
@ -2852,7 +2852,7 @@ static void do_compile(EditState *s, const char *cmd)
|
|||
set_error_offset(b, 0);
|
||||
}
|
||||
|
||||
static void do_compile_error(EditState *s, int arg, int dir)
|
||||
static void do_compile_error(EditState *s, int dir, int arg)
|
||||
{
|
||||
QEmacsState *qs = s->qe_state;
|
||||
EditState *e;
|
||||
|
|
@ -3128,9 +3128,9 @@ static CmdDef shell_global_commands[] = {
|
|||
"man", do_man, ESs,
|
||||
"s{Show man page for: }|man|")
|
||||
CMD3( KEY_CTRLX(KEY_CTRL('p')), KEY_NONE,
|
||||
"previous-error", do_compile_error, ESii, -1, "uiv")
|
||||
"previous-error", do_compile_error, ESii, -1, "vui")
|
||||
CMD3( KEY_CTRLX(KEY_CTRL('n')), KEY_CTRLX('`'),
|
||||
"next-error", do_compile_error, ESii, 1, "uiv")
|
||||
"next-error", do_compile_error, ESii, 1, "vui")
|
||||
CMD_DEF_END,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue