return 1;
}
-DEF_CMD(doc_notify)
+DEF_CMD_CLOSED(doc_notify)
{
/* Key is "doc:notify:..." */
int ret = pane_notify(ksuffix(ci, "doc:notify:"),
call("editor:notify:Message:broadcast",
owner, 0, NULL,
"WARNING mark not freed by Close:mark");
- LOG("WARNING Mark not freed by Close:mark");
+ LOG("WARNING Mark on %s not freed by Close:mark",
+ owner->name);
warned = True;
}
m->mdata = NULL;
return 1;
}
-DEF_CMD(doc_pass_on)
+DEF_CMD_CLOSED(doc_pass_on)
{
struct doc_data *dd = ci->home->data;
int ret = home_call(dd->doc, ci->key, ci->focus, ci->num,
struct pane ;
struct command {
- int (*func)(const struct cmd_info *ci safe);
- int refcnt; /* only if 'free' is not NULL */
- void (*free)(struct command *c safe);
- const char *name;
+ int (*func)(const struct cmd_info *ci safe);
+ unsigned int refcnt; /* only if 'free' is not NULL */
+ unsigned int closed_ok:1;
+ void (*free)(struct command *c safe);
+ const char *name;
};
enum edlib_errors {
static inline void command_put(struct command *c)
{
- if (c && c->free && c->refcnt-- == 1)
+ if (c && c->free && --c->refcnt == 0)
c->free(c);
}
struct map **m safe;
};
-#define CMD(_name) {.func = _name ## _func , \
- .refcnt = 0, \
- .free = NULL, \
- .name = # _name, \
+#define CMD(_name) { \
+ .func = _name ## _func , \
+ .refcnt = 0, \
+ .closed_ok = 0, \
+ .free = NULL, \
+ .name = # _name, \
+ }
+#define CMD_CLOSED(_name) { \
+ .func = _name ## _func , \
+ .refcnt = 0, \
+ .closed_ok = 1, \
+ .free = NULL, \
+ .name = # _name, \
}
#define CB(_name) {.func = _name ## _func , \
.refcnt = 0, \
+ .closed_ok = 0, \
.free = NULL, \
.name = # _name, \
}
static int _name ## _func(const struct cmd_info *ci safe); \
static struct command _name = CMD(_name); \
static int _name ## _func(const struct cmd_info *ci safe)
+#define DEF_CMD_CLOSED(_name) \
+ static int _name ## _func(const struct cmd_info *ci safe); \
+ static struct command _name = CMD_CLOSED(_name); \
+ static int _name ## _func(const struct cmd_info *ci safe)
#define REDEF_CMD(_name) \
static int _name ## _func(const struct cmd_info *ci safe)
#define DEF_EXTERN_CMD(_name) \
static struct lookup_cmd _name = { \
.c.func = key_lookup_cmd_func, \
.c.refcnt = 0, \
+ .c.closed_ok = 1, \
.c.free = NULL, \
.c.name = #_name, \
.m = &_map, \
static struct pfx_cmd _name = { \
.c.func = key_pfx_func, \
.c.refcnt = 0, \
+ .c.closed_ok = 1, \
.c.free = NULL, \
.c.name = "prefix" #_pfx, \
.pfx = _pfx, \
c->c = python_call;
c->c.free = python_free_command;
c->c.refcnt = 0;
+ c->c.closed_ok = 0;
command_get(&c->c);
Py_INCREF(callable);
c->callable = callable;
self->map = key_alloc();
key_add(self->map, "Close:mark", &python_close_mark);
self->cmd = python_pane_call;
+ self->cmd.closed_ok = 1;
self->cmd.free = python_pane_free;
if (self->ob_base.ob_type)
self->cmd.name = self->ob_base.ob_type->tp_name;