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