1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
/* $OpenBSD: funmap.c,v 1.47 2013/05/31 18:03:44 lum Exp $ */
/* This file is in the public domain */
#include "def.h"
#include "kbd.h"
#include "funmap.h"
/*
* If the function is NULL, it must be listed with the
* same name in the map_table.
*/
struct funmap {
PF fn_funct;
const char *fn_name;
struct funmap *fn_next;
};
static struct funmap *funs;
static struct funmap functnames[] = {
{apropos_command, "apropos",},
{toggleaudiblebell, "audible-bell",},
{auto_execute, "auto-execute",},
{fillmode, "auto-fill-mode",},
{indentmode, "auto-indent-mode",},
{backtoindent, "back-to-indentation",},
{backuptohomedir, "backup-to-home-directory",},
{backchar, "backward-char",},
{delbword, "backward-kill-word",},
{gotobop, "backward-paragraph",},
{backword, "backward-word",},
{gotobob, "beginning-of-buffer",},
{gotobol, "beginning-of-line",},
{showmatch, "blink-and-insert",},
{bsmap, "bsmap-mode",},
{NULL, "c-x 4 prefix",},
{NULL, "c-x prefix",},
{executemacro, "call-last-kbd-macro",},
{capword, "capitalize-word",},
{changedir, "cd",},
{clearmark, "clear-mark",},
{colnotoggle, "column-number-mode",},
{copyregion, "copy-region-as-kill",},
#ifdef REGEX
{cntmatchlines, "count-matches",},
{cntnonmatchlines, "count-non-matches",},
#endif /* REGEX */
{cscreatelist, "cscope-create-list-of-files-to-index",},
{csfuncalled, "cscope-find-called-functions",},
{csegrep, "cscope-find-egrep-pattern",},
{csfindinc, "cscope-find-files-including-file",},
{cscallerfuncs, "cscope-find-functions-calling-this-function",},
{csdefinition, "cscope-find-global-definition",},
{csfindfile, "cscope-find-this-file",},
{cssymbol, "cscope-find-this-symbol",},
{csfindtext, "cscope-find-this-text-string",},
{csnextfile, "cscope-next-file",},
{csnextmatch, "cscope-next-symbol",},
{csprevfile, "cscope-prev-file",},
{csprevmatch, "cscope-prev-symbol",},
{redefine_key, "define-key",},
{backdel, "delete-backward-char",},
{deblank, "delete-blank-lines",},
{forwdel, "delete-char",},
{delwhite, "delete-horizontal-space",},
{delleadwhite, "delete-leading-space",},
#ifdef REGEX
{delmatchlines, "delete-matching-lines",},
{delnonmatchlines, "delete-non-matching-lines",},
#endif /* REGEX */
{onlywind, "delete-other-windows",},
{deltrailwhite, "delete-trailing-space",},
{delwind, "delete-window",},
{wallchart, "describe-bindings",},
{desckey, "describe-key-briefly",},
{diffbuffer, "diff-buffer-with-file",},
{digit_argument, "digit-argument",},
{lowerregion, "downcase-region",},
{lowerword, "downcase-word",},
{showversion, "emacs-version",},
{finishmacro, "end-kbd-macro",},
{gotoeob, "end-of-buffer",},
{gotoeol, "end-of-line",},
{enlargewind, "enlarge-window",},
{NULL, "esc prefix",},
{evalbuffer, "eval-current-buffer",},
{evalexpr, "eval-expression",},
{swapmark, "exchange-point-and-mark",},
{extend, "execute-extended-command",},
{fillpara, "fill-paragraph",},
{filevisitalt, "find-alternate-file",},
{filevisit, "find-file",},
{poptofile, "find-file-other-window",},
{filevisitro, "find-file-read-only",},
{findtag, "find-tag",},
{forwchar, "forward-char",},
{gotoeop, "forward-paragraph",},
{forwword, "forward-word",},
{bindtokey, "global-set-key",},
{unbindtokey, "global-unset-key",},
{globalwdtoggle, "global-wd-mode",},
{gotoline, "goto-line",},
{help_help, "help-help",},
{indent, "indent-current-line",},
{insert, "insert",},
{bufferinsert, "insert-buffer",},
{fileinsert, "insert-file",},
{fillword, "insert-with-wrap",},
{backisearch, "isearch-backward",},
{forwisearch, "isearch-forward",},
{joinline, "join-line",},
{justone, "just-one-space",},
{ctrlg, "keyboard-quit",},
{killbuffer_cmd, "kill-buffer",},
{killline, "kill-line",},
{killpara, "kill-paragraph",},
{killregion, "kill-region",},
{delfword, "kill-word",},
{toggleleavetmp, "leave-tmpdir-backups",},
{linenotoggle, "line-number-mode",},
{listbuffers, "list-buffers",},
{evalfile, "load",},
{localbind, "local-set-key",},
{localunbind, "local-unset-key",},
{makebkfile, "make-backup-files",},
{makedir, "make-directory",},
{markbuffer, "mark-whole-buffer",},
{do_meta, "meta-key-mode",}, /* better name, anyone? */
{negative_argument, "negative-argument",},
{newline, "newline",},
{lfindent, "newline-and-indent",},
{forwline, "next-line",},
#ifdef NOTAB
{notabmode, "no-tab-mode",},
#endif /* NOTAB */
{notmodified, "not-modified",},
{openline, "open-line",},
{nextwind, "other-window",},
{overwrite_mode, "overwrite-mode",},
{poptag, "pop-tag-mark",},
{prefixregion, "prefix-region",},
{backline, "previous-line",},
{prevwind, "previous-window",},
{spawncli, "push-shell",},
{showcwdir, "pwd",},
{queryrepl, "query-replace",},
#ifdef REGEX
{re_queryrepl, "query-replace-regexp",},
#endif /* REGEX */
{quote, "quoted-insert",},
#ifdef REGEX
{re_searchagain, "re-search-again",},
{re_backsearch, "re-search-backward",},
{re_forwsearch, "re-search-forward",},
#endif /* REGEX */
{reposition, "recenter",},
{redraw, "redraw-display",},
#ifdef REGEX
{replstr, "replace-string",},
#endif /* REGEX */
{revertbuffer, "revert-buffer",},
{filesave, "save-buffer",},
{quit, "save-buffers-kill-emacs",},
{savebuffers, "save-some-buffers",},
{backpage, "scroll-down",},
{back1page, "scroll-one-line-down",},
{forw1page, "scroll-one-line-up",},
{pagenext, "scroll-other-window",},
{forwpage, "scroll-up",},
{searchagain, "search-again",},
{backsearch, "search-backward",},
{forwsearch, "search-forward",},
{selfinsert, "self-insert-command",},
#ifdef REGEX
{setcasefold, "set-case-fold-search",},
#endif /* REGEX */
{set_default_mode, "set-default-mode",},
{setfillcol, "set-fill-column",},
{setmark, "set-mark-command",},
{setprefix, "set-prefix-string",},
{shellcommand, "shell-command",},
{piperegion, "shell-command-on-region",},
{shrinkwind, "shrink-window",},
#ifdef NOTAB
{space_to_tabstop, "space-to-tabstop",},
#endif /* NOTAB */
{splitwind, "split-window-vertically",},
{definemacro, "start-kbd-macro",},
{spawncli, "suspend-emacs",},
{usebuffer, "switch-to-buffer",},
{poptobuffer, "switch-to-buffer-other-window",},
{togglereadonly, "toggle-read-only" },
{twiddle, "transpose-chars",},
{undo, "undo",},
{undo_add_boundary, "undo-boundary",},
{undo_boundary_enable, "undo-boundary-toggle",},
{undo_enable, "undo-enable",},
{undo_dump, "undo-list",},
{universal_argument, "universal-argument",},
{upperregion, "upcase-region",},
{upperword, "upcase-word",},
{togglevisiblebell, "visible-bell",},
{tagsvisit, "visit-tags-table",},
{showcpos, "what-cursor-position",},
{filewrite, "write-file",},
{yank, "yank",},
{NULL, NULL,}
};
void
funmap_init(void)
{
struct funmap *fn;
for (fn = functnames; fn->fn_name != NULL; fn++) {
fn->fn_next = funs;
funs = fn;
}
}
int
funmap_add(PF fun, const char *fname)
{
struct funmap *fn;
if ((fn = malloc(sizeof(*fn))) == NULL)
return (FALSE);
fn->fn_funct = fun;
fn->fn_name = fname;
fn->fn_next = funs;
funs = fn;
return (TRUE);
}
/*
* Translate from function name to function pointer.
*/
PF
name_function(const char *fname)
{
struct funmap *fn;
for (fn = funs; fn != NULL; fn = fn->fn_next) {
if (strcmp(fn->fn_name, fname) == 0)
return (fn->fn_funct);
}
return (NULL);
}
const char *
function_name(PF fun)
{
struct funmap *fn;
for (fn = funs; fn != NULL; fn = fn->fn_next) {
if (fn->fn_funct == fun)
return (fn->fn_name);
}
return (NULL);
}
/*
* List possible function name completions.
*/
struct list *
complete_function_list(const char *fname)
{
struct funmap *fn;
struct list *head, *el;
int len;
len = strlen(fname);
head = NULL;
for (fn = funs; fn != NULL; fn = fn->fn_next) {
if (memcmp(fname, fn->fn_name, len) == 0) {
if ((el = malloc(sizeof(*el))) == NULL) {
free_file_list(head);
return (NULL);
}
el->l_name = strdup(fn->fn_name);
el->l_next = head;
head = el;
}
}
return (head);
}
|