K:M:C:Up is Meta-Control-Up
K:M:C-U is Meta-Control-U
K:Cx-f is Control-X f -- assuming K:C-x causes Cx to be set as prefix.
-- [ ] add key_add_prefix()
+- [X] add key_add_prefix()
- [ ] ?? restrict prefix key lookup to punctuation.
Current ranges are:
### grep/make
+- [ ] leave marks at every match as soon as possible
- [ ] clarify and document the role of numeric args to git-grep
- [ ] make/grep - when insert at end-of-file, a pointer that was at EOF should
stay there.
doc_default_cmd = key_alloc();
doc_handle_cmd = key_alloc();
- key_add_range(doc_handle_cmd, "doc:", "doc;", &doc_pass_on);
+ key_add_prefix(doc_handle_cmd, "doc:", &doc_pass_on);
key_add(doc_handle_cmd, "Move-Char", &doc_char);
key_add(doc_handle_cmd, "Move-Word", &doc_word);
key_add(doc_default_cmd, "doc:pop-point", &doc_pop_point);
key_add(doc_default_cmd, "doc:attach-view", &doc_attach_view);
- key_add_range(doc_default_cmd, "doc:Request:Notify:", "doc:Request:Notify;",
- &doc_request_notify);
- key_add_range(doc_default_cmd, "doc:Notify:", "doc:Notify;",
- &doc_notify);
- key_add_range(doc_default_cmd, "doc:set:", "doc:set;",
- &doc_set);
+ key_add_prefix(doc_default_cmd, "doc:Request:Notify:", &doc_request_notify);
+ key_add_prefix(doc_default_cmd, "doc:Notify:", &doc_notify);
+ key_add_prefix(doc_default_cmd, "doc:set:", &doc_set);
}
static void do_doc_assign(struct pane *p safe, struct pane *doc safe)
key_add(ed_map, "global-get-command", &global_get_command);
key_add(ed_map, "global-load-module", &editor_load_module);
key_add(ed_map, "editor-on-idle", &editor_on_idle);
- key_add_range(ed_map, "attach-", "attach.", &editor_auto_load);
- key_add_range(ed_map, "event:", "event;", &editor_auto_event);
- key_add_range(ed_map, "global-multicall-", "global-multicall.",
- &editor_multicall);
- key_add_range(ed_map, "Request:Notify:global-", "Request:Notify:global.",
- &editor_global_request_notify);
- key_add_range(ed_map, "Call:Notify:global-", "Call:Notify:global.",
- &editor_global_notify);
+ key_add_prefix(ed_map, "attach-", &editor_auto_load);
+ key_add_prefix(ed_map, "event:", &editor_auto_event);
+ key_add_prefix(ed_map, "global-multicall-", &editor_multicall);
+ key_add_prefix(ed_map, "Request:Notify:global-",
+ &editor_global_request_notify);
+ key_add_prefix(ed_map, "Call:Notify:global-",
+ &editor_global_notify);
key_add(ed_map, "Close", &editor_close);
}
ei->map = key_alloc();
* A keymap maps a key to a command.
* Keys are ordered for fast binary-search lookup.
* A "key" is an arbitrary string which typically contains
- * some 'mode' pr efix and some specific tail.
+ * some 'mode' prefix and some specific tail.
* e.g emacs-M-C-Chr-x is Meta-Control-X in emacs mode.
* As far as the map is concerned, it is just a lexically order string.
*
* lsb clear.
*
* If a key is registered a second time, the new over-rides the old.
- * This is particularly useful for registering a range, and then some exception.
+ * This is particularly useful for registering a range, and then some exceptions.
* To delete a key from a range we need to make two ranges, one that ends
* just before the new key, one that starts just after.
* The 'ends just before' is easy - we just add the new key or range.
* Then insert a stand-alone for 'last' and update 'pos' to be a range-start.
*/
if (pos2 - 1 > pos && IS_RANGE(map->comms[pos2-1])) {
- map->keys[pos2-1] = last;
+ free(map->keys[pos2-1]);
+ map->keys[pos2-1] = strdup(last);
pos2 -= 1;
}
/* Need to insert 'last', and remove extras. so +1 and -(pos2-pos-1); */
char *strsave(struct pane *p safe, char *buf);
char *strnsave(struct pane *p safe, char *buf, int len);
char * safe __strconcat(struct pane *p safe, char *s1 safe, ...);
-#define strconcat(p, s1, ...) __strconcat(p, s1, __VA_ARGS__, NULL)
+#define strconcat(p, ...) __strconcat(p, __VA_ARGS__, NULL)
/* This is declared here so sparse knows it is global */
void edlib_init(struct pane *ed safe);
void key_add(struct map *map safe, char *k safe, struct command *comm);
void key_add_range(struct map *map safe, char *first safe, char *last safe,
struct command *comm);
+#define key_add_prefix(map, prefix, comm) \
+ key_add_range(map, prefix, prefix "\xFF\xFF\xFF\xFF", comm)
void key_add_chain(struct map *map safe, struct map *chain);
struct command *key_register_prefix(char *name safe);
key_add(mp_map, "Notify:Close", &mp_notify_close);
key_add(mp_map, "Notify:doc:viewers", &mp_notify_viewers);
key_add(mp_map, "multipart-add", &mp_add);
- key_add_range(mp_map, "multipart-this:", "multipart-this;", &mp_forward);
- key_add_range(mp_map, "multipart-next:", "multipart-next;", &mp_forward);
- key_add_range(mp_map, "multipart-prev:", "multipart-prev;", &mp_forward);
+ key_add_prefix(mp_map, "multipart-this:", &mp_forward);
+ key_add_prefix(mp_map, "multipart-next:", &mp_forward);
+ key_add_prefix(mp_map, "multipart-prev:", &mp_forward);
}
DEF_LOOKUP_CMD(mp_handle, mp_map);
PyObject *l = PyObject_Dir(refer);
int n = PyList_Size(l);
- if (!self->map)
+ if (!self->map || !self->pane)
return;
for (i = 0; i < n ; i++) {
PyObject *e = PyList_GetItem(l, i);
command_put(&comm->c);
}
}
+ if (docs &&
+ strncmp(docs, "handle-prefix:", 14) == 0) {
+ char *a = strconcat(self->pane, docs+14);
+ char *b = strconcat(self->pane,
+ a, "\xFF\xFF\xFF\xFF");
+ struct python_command *comm =
+ malloc(sizeof(*comm));
+ comm->c = python_call;
+ comm->c.free = python_free_command;
+ command_get(&comm->c);
+ Py_INCREF(m);
+ comm->callable = m;
+ key_add_range(self->map, a, b,
+ &comm->c);
+ command_put(&comm->c);
+ }
if (docs &&
strncmp(docs, "handle-list", 11) == 0 &&
docs[11]) {
if ((void*)crop_map)
return;
crop_map = key_alloc();
- key_add_range(crop_map, "doc:", "doc;", &crop_generic);
+ key_add_prefix(crop_map, "doc:", &crop_generic);
key_add(crop_map, "Close", &crop_close);
key_add(crop_map, "doc:write_file", &crop_write);
key_add(crop_map, "doc:step", &crop_step);
key_add(im_map, "Mode:set-num2", &set_num2);
key_add(im_map, "pane:refocus", &refocus);
key_add(im_map, "Notify:Close", &close_focus);
- key_add_range(im_map, "Request:Notify:", "Request:Notify;", &request_notify);
+ key_add_prefix(im_map, "Request:Notify:", &request_notify);
}
DEF_LOOKUP_CMD(input_handle, im_map);
return 1
def handle_notmuch_remove_tag(self, key, str, str2, **a):
- "handle-range/doc:notmuch:remove-tag-/doc:notmuch:remove-tag./"
+ "handle-prefix:doc:notmuch:remove-tag-"
tag = key[23:]
with self.db.get_write() as db:
if str2:
return os.path.dirname(path)+'/'+f
def handle_present_bg(self, key, focus, mark, mark2, num, comm2, **a):
- "handle-range/Present-BG:/Present-BG;/"
+ "handle-prefix:Present-BG:"
cmds = key[11:].split(',')
ret = 0
for c in cmds:
key_add_range(rc_map, "Chr- ", "Chr-~", &complete_char);
key_add(rc_map, "Backspace", &complete_bs);
- key_add_range(rc_map, "Move-", "Move-\377", &complete_nomove);
+ key_add_prefix(rc_map, "Move-", &complete_nomove);
key_add(rc_map, "Move-EOL", &complete_eol);
key_add(rc_map, "Enter", &complete_return);
{
rl_map = key_alloc();
- key_add_range(rl_map, "Move-", "Move-\377", &render_lines_other_move);
+ key_add_prefix(rl_map, "Move-", &render_lines_other_move);
key_add(rl_map, "Move-View-Small", &render_lines_move);
key_add(rl_map, "Move-View-Large", &render_lines_move);
key_add(rl_map, "Move-View-Pos", &render_lines_move_pos);