summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/mg/Makefile4
-rw-r--r--usr.bin/mg/def.h5
-rw-r--r--usr.bin/mg/echo.c8
-rw-r--r--usr.bin/mg/extend.c3
-rw-r--r--usr.bin/mg/funmap.c296
-rw-r--r--usr.bin/mg/funmap.h5
-rw-r--r--usr.bin/mg/help.c3
-rw-r--r--usr.bin/mg/kbd.h9
-rw-r--r--usr.bin/mg/keymap.c315
-rw-r--r--usr.bin/mg/main.c4
10 files changed, 320 insertions, 332 deletions
diff --git a/usr.bin/mg/Makefile b/usr.bin/mg/Makefile
index 8c726d3a5cf..8eee50f5e20 100644
--- a/usr.bin/mg/Makefile
+++ b/usr.bin/mg/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.6 2000/09/01 14:59:08 millert Exp $
+# $OpenBSD: Makefile,v 1.7 2001/05/24 09:47:33 art Exp $
PROG= mg
@@ -22,6 +22,6 @@ SRCS= cinfo.c fileio.c spawn.c ttyio.c tty.c ttykbd.c \
basic.c dir.c dired.c file.c line.c match.c paragraph.c \
random.c region.c search.c version.c window.c word.c \
buffer.c display.c echo.c extend.c help.c kbd.c keymap.c \
- macro.c main.c modes.c re_search.c
+ macro.c main.c modes.c re_search.c funmap.c
.include <bsd.prog.mk>
diff --git a/usr.bin/mg/def.h b/usr.bin/mg/def.h
index 7920ba6ab64..e4b41553df0 100644
--- a/usr.bin/mg/def.h
+++ b/usr.bin/mg/def.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: def.h,v 1.18 2001/05/24 03:05:20 mickey Exp $ */
+/* $OpenBSD: def.h,v 1.19 2001/05/24 09:47:33 art Exp $ */
/*
* This file is the general header file for all parts
@@ -388,9 +388,6 @@ BUFFER *dired_ __P((char *));
int d_makename __P((LINE *, char *));
LIST *make_file_list __P((char *));
-/* keymap.c X */
-LIST *complete_function_list __P((char *, int));
-
/* kbd.c X */
int do_meta __P((int, int));
int bsmap __P((int, int));
diff --git a/usr.bin/mg/echo.c b/usr.bin/mg/echo.c
index 212e8e3a4fe..4c41ef13f22 100644
--- a/usr.bin/mg/echo.c
+++ b/usr.bin/mg/echo.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: echo.c,v 1.15 2001/05/24 09:34:05 mickey Exp $ */
+/* $OpenBSD: echo.c,v 1.16 2001/05/24 09:47:33 art Exp $ */
/*
* Echo line reading and writing.
@@ -13,6 +13,8 @@
#include "macro.h"
#endif /* !NO_MACRO */
+#include "funmap.h"
+
#include <stdarg.h>
static int veread __P((const char *, char *buf, int, int, va_list));
@@ -175,6 +177,10 @@ veread(const char *fp, char *buf, int nbuf, int flag, va_list ap)
} else
eputc(' ');
eformat(fp, ap);
+ if ((flag & EFDEF) != 0) {
+ eputs(buf);
+ cpos += strlen(buf);
+ }
tteeol();
ttflush();
for (;;) {
diff --git a/usr.bin/mg/extend.c b/usr.bin/mg/extend.c
index d24770dc2f6..5ef729af5df 100644
--- a/usr.bin/mg/extend.c
+++ b/usr.bin/mg/extend.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: extend.c,v 1.15 2001/05/24 03:05:22 mickey Exp $ */
+/* $OpenBSD: extend.c,v 1.16 2001/05/24 09:47:33 art Exp $ */
/*
* Extended (M-X) commands, rebinding, and startup file processing.
@@ -6,6 +6,7 @@
#include "def.h"
#include "kbd.h"
+#include "funmap.h"
#ifndef NO_MACRO
#include "macro.h"
diff --git a/usr.bin/mg/funmap.c b/usr.bin/mg/funmap.c
new file mode 100644
index 00000000000..9aad4d290d9
--- /dev/null
+++ b/usr.bin/mg/funmap.c
@@ -0,0 +1,296 @@
+#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;
+ char *fn_name;
+ struct funmap *fn_next;
+};
+
+static struct funmap *funs;
+
+static struct funmap functnames[] = {
+#ifndef NO_HELP
+ {apropos_command, "apropos",},
+#endif /* !NO_HELP */
+ {fillmode, "auto-fill-mode",},
+ {indentmode, "auto-indent-mode",},
+ {backchar, "backward-char",},
+ {delbword, "backward-kill-word",},
+ {gotobop, "backward-paragraph",},
+ {backword, "backward-word",},
+ {gotobob, "beginning-of-buffer",},
+ {gotobol, "beginning-of-line",},
+ {blinkparen, "blink-matching-paren",},
+ {showmatch, "blink-matching-paren-hack",},
+#ifdef BSMAP
+ {bsmap, "bsmap-mode",},
+#endif /* BSMAP */
+ {NULL, "c-x 4 prefix",},
+ {NULL, "c-x prefix",},
+#ifndef NO_MACRO
+ {executemacro, "call-last-kbd-macro",},
+#endif /* !NO_MACRO */
+ {capword, "capitalize-word",},
+#ifndef NO_DIR
+ {changedir, "cd",},
+#endif /* !NO_DIR */
+ {copyregion, "copy-region-as-kill",},
+#ifdef REGEX
+ {cntmatchlines, "count-matches",},
+ {cntnonmatchlines, "count-non-matches",},
+#endif /* REGEX */
+ {define_key, "define-key",},
+ {backdel, "delete-backward-char",},
+ {deblank, "delete-blank-lines",},
+ {forwdel, "delete-char",},
+ {delwhite, "delete-horizontal-space",},
+#ifdef REGEX
+ {delmatchlines, "delete-matching-lines",},
+ {delnonmatchlines, "delete-non-matching-lines",},
+#endif /* REGEX */
+ {onlywind, "delete-other-windows",},
+ {delwind, "delete-window",},
+#ifndef NO_HELP
+ {wallchart, "describe-bindings",},
+ {desckey, "describe-key-briefly",},
+#endif /* !NO_HELP */
+ {digit_argument, "digit-argument",},
+#ifndef NO_DIRED
+ {dired, "dired",},
+ {d_undelbak, "dired-backup-unflag",},
+ {d_copy, "dired-copy-file",},
+ {d_expunge, "dired-do-deletions",},
+ {d_findfile, "dired-find-file",},
+ {d_ffotherwindow, "dired-find-file-other-window",},
+ {d_del, "dired-flag-file-deleted",},
+ {d_otherwindow, "dired-other-window",},
+ {d_rename, "dired-rename-file",},
+ {d_undel, "dired-unflag",},
+#endif /* !NO_DIRED */
+ {lowerregion, "downcase-region",},
+ {lowerword, "downcase-word",},
+ {showversion, "emacs-version",},
+#ifndef NO_MACRO
+ {finishmacro, "end-kbd-macro",},
+#endif /* !NO_MACRO */
+ {gotoeob, "end-of-buffer",},
+ {gotoeol, "end-of-line",},
+ {enlargewind, "enlarge-window",},
+ {NULL, "esc prefix",},
+#ifndef NO_STARTUP
+ {evalbuffer, "eval-current-buffer",},
+ {evalexpr, "eval-expression",},
+#endif /* !NO_STARTUP */
+ {swapmark, "exchange-point-and-mark",},
+ {extend, "execute-extended-command",},
+ {NULL, "extra prefix 1",},
+ {NULL, "extra prefix 2",},
+ {NULL, "extra prefix 3",},
+ {NULL, "extra prefix 4",},
+ {NULL, "extra prefix 5",},
+ {fillpara, "fill-paragraph",},
+ {filevisit, "find-file",},
+ {poptofile, "find-file-other-window",},
+ {forwchar, "forward-char",},
+ {gotoeop, "forward-paragraph",},
+ {forwword, "forward-word",},
+ {bindtokey, "global-set-key",},
+ {unbindtokey, "global-unset-key",},
+ {gotoline, "goto-line",},
+#ifndef NO_HELP
+ {NULL, "help",},
+ {help_help, "help-help",},
+#endif /* !NO_HELP */
+ {insert, "insert",},
+ {bufferinsert, "insert-buffer",},
+ {fileinsert, "insert-file",},
+ {fillword, "insert-with-wrap",},
+ {backisearch, "isearch-backward",},
+ {forwisearch, "isearch-forward",},
+ {justone, "just-one-space",},
+ {ctrlg, "keyboard-quit",},
+ {killbuffer, "kill-buffer",},
+ {killline, "kill-line",},
+ {killpara, "kill-paragraph",},
+ {killregion, "kill-region",},
+ {delfword, "kill-word",},
+ {listbuffers, "list-buffers",},
+#ifndef NO_STARTUP
+ {evalfile, "load",},
+#endif /* !NO_STARTUP */
+ {localbind, "local-set-key",},
+ {localunbind, "local-unset-key",},
+#ifndef NO_BACKUP
+ {makebkfile, "make-backup-files",},
+#endif /* !NO_BACKUP */
+#ifdef DO_METAKEY
+ {do_meta, "meta-key-mode",}, /* better name, anyone? */
+#endif /* DO_METAKEY */
+ {negative_argument, "negative-argument",},
+ {newline, "newline",},
+ {indent, "newline-and-indent",},
+ {forwline, "next-line",},
+#ifdef NOTAB
+ {notabmode, "no-tab-mode",},
+#endif /* NOTAB */
+ {notmodified, "not-modified",},
+ {openline, "open-line",},
+ {nextwind, "other-window",},
+ {overwrite, "overwrite-mode",},
+#ifdef PREFIXREGION
+ {prefixregion, "prefix-region",},
+#endif /* PREFIXREGION */
+ {backline, "previous-line",},
+#ifdef GOSMACS
+ {prevwind, "previous-window",},
+#endif /* GOSEMACS */
+ {spawncli, "push-shell",},
+#ifndef NO_DIR
+ {showcwdir, "pwd",},
+#endif /* !NO_DIR */
+ {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",},
+ {refresh, "redraw-display",},
+ {filesave, "save-buffer",},
+ {quit, "save-buffers-kill-emacs",},
+ {savebuffers, "save-some-buffers",},
+ {backpage, "scroll-down",},
+#ifdef GOSMACS
+ {back1page, "scroll-one-line-down",},
+ {forw1page, "scroll-one-line-up",},
+#endif /* GOSMACS */
+ {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",},
+#ifdef PREFIXREGION
+ {setprefix, "set-prefix-string",},
+#endif /* PREFIXREGION */
+ {shrinkwind, "shrink-window",},
+#ifdef NOTAB
+ {space_to_tabstop, "space-to-tabstop",},
+#endif /* NOTAB */
+ {splitwind, "split-window-vertically",},
+#ifndef NO_MACRO
+ {definemacro, "start-kbd-macro",},
+#endif /* !NO_MACRO */
+ {spawncli, "suspend-emacs",},
+ {usebuffer, "switch-to-buffer",},
+ {poptobuffer, "switch-to-buffer-other-window",},
+ {twiddle, "transpose-chars",},
+ {universal_argument, "universal-argument",},
+ {upperregion, "upcase-region",},
+ {upperword, "upcase-word",},
+ {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, 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(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;
+}
+
+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.
+ */
+LIST *
+complete_function_list(char *fname, int c)
+{
+ struct funmap *fn;
+ 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 = fn->fn_name;
+ el->l_next = head;
+ head = el;
+ }
+ }
+
+ return head;
+}
+
+
+
diff --git a/usr.bin/mg/funmap.h b/usr.bin/mg/funmap.h
new file mode 100644
index 00000000000..47d8b298c5e
--- /dev/null
+++ b/usr.bin/mg/funmap.h
@@ -0,0 +1,5 @@
+void funmap_init(void);
+PF name_function(char *);
+char *function_name(PF);
+LIST *complete_function_list(char *, int);
+int funmap_add(PF, char *);
diff --git a/usr.bin/mg/help.c b/usr.bin/mg/help.c
index 1684c16fa30..9f320079dd2 100644
--- a/usr.bin/mg/help.c
+++ b/usr.bin/mg/help.c
@@ -1,10 +1,11 @@
-/* $OpenBSD: help.c,v 1.13 2001/05/24 09:06:21 art Exp $ */
+/* $OpenBSD: help.c,v 1.14 2001/05/24 09:47:34 art Exp $ */
/*
* Help functions for Mg 2
*/
#include "def.h"
+#include "funmap.h"
#ifndef NO_HELP
#include "kbd.h"
diff --git a/usr.bin/mg/kbd.h b/usr.bin/mg/kbd.h
index 33dc4f81cdc..ea3dfa990dc 100644
--- a/usr.bin/mg/kbd.h
+++ b/usr.bin/mg/kbd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: kbd.h,v 1.10 2001/05/24 03:05:23 mickey Exp $ */
+/* $OpenBSD: kbd.h,v 1.11 2001/05/24 09:47:34 art Exp $ */
/*
* kbd.h: type definitions for symbol.c and kbd.c for mg experimental
@@ -43,17 +43,10 @@ typedef struct MAPS_S {
extern MAPS map_table[];
extern KEYMAP *fundamental_map;
-typedef struct {
- PF n_funct;
- char *n_name;
-} FUNCTNAMES;
-
int dobindkey __P((KEYMAP *, char *, char *));
KEYMAP *name_map __P((char *));
MAPS *name_mode __P((char *));
PF doscan __P((KEYMAP *, int, KEYMAP **));
-PF name_function __P((char *));
-char *function_name __P((PF));
char *map_name __P((KEYMAP *));
extern MAP_ELEMENT *ele;
diff --git a/usr.bin/mg/keymap.c b/usr.bin/mg/keymap.c
index d99f3ddd1b8..2bb7b482686 100644
--- a/usr.bin/mg/keymap.c
+++ b/usr.bin/mg/keymap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: keymap.c,v 1.11 2001/05/23 22:56:52 mickey Exp $ */
+/* $OpenBSD: keymap.c,v 1.12 2001/05/24 09:47:34 art Exp $ */
/*
* Keyboard maps. This is character set dependent. The terminal specific
@@ -8,8 +8,6 @@
#include "def.h"
#include "kbd.h"
-static int name_fent __P((char *, int));
-
/*
* initial keymap declarations, deepest first
*/
@@ -651,314 +649,3 @@ name_map(name)
return (mp = name_mode(name)) == NULL ? NULL : mp->p_map;
}
-/*
- * Warning: functnames MUST be in alphabetical order! (due to binary search
- * in name_function.) If the function is NULL, it must be listed with the
- * same name in the map_table above.
- */
-const FUNCTNAMES functnames[] = {
-#ifndef NO_HELP
- {apropos_command, "apropos"},
-#endif /* !NO_HELP */
- {fillmode, "auto-fill-mode"},
- {indentmode, "auto-indent-mode"},
- {backchar, "backward-char"},
- {delbword, "backward-kill-word"},
- {gotobop, "backward-paragraph"},
- {backword, "backward-word"},
- {gotobob, "beginning-of-buffer"},
- {gotobol, "beginning-of-line"},
- {blinkparen, "blink-matching-paren"},
- {showmatch, "blink-matching-paren-hack"},
-#ifdef BSMAP
- {bsmap, "bsmap-mode"},
-#endif /* BSMAP */
- {NULL, "c-x 4 prefix"},
- {NULL, "c-x prefix"},
-#ifndef NO_MACRO
- {executemacro, "call-last-kbd-macro"},
-#endif /* !NO_MACRO */
- {capword, "capitalize-word"},
-#ifndef NO_DIR
- {changedir, "cd"},
-#endif /* !NO_DIR */
- {copyregion, "copy-region-as-kill"},
-#ifdef REGEX
- {cntmatchlines, "count-matches"},
- {cntnonmatchlines, "count-non-matches"},
-#endif /* REGEX */
- {define_key, "define-key"},
- {backdel, "delete-backward-char"},
- {deblank, "delete-blank-lines"},
- {forwdel, "delete-char"},
- {delwhite, "delete-horizontal-space"},
-#ifdef REGEX
- {delmatchlines, "delete-matching-lines"},
- {delnonmatchlines, "delete-non-matching-lines"},
-#endif /* REGEX */
- {onlywind, "delete-other-windows"},
- {delwind, "delete-window"},
-#ifndef NO_HELP
- {wallchart, "describe-bindings"},
- {desckey, "describe-key-briefly"},
-#endif /* !NO_HELP */
- {digit_argument, "digit-argument"},
-#ifndef NO_DIRED
- {dired, "dired"},
- {d_undelbak, "dired-backup-unflag"},
- {d_copy, "dired-copy-file"},
- {d_expunge, "dired-do-deletions"},
- {d_findfile, "dired-find-file"},
- {d_ffotherwindow, "dired-find-file-other-window"},
- {d_del, "dired-flag-file-deleted"},
- {d_otherwindow, "dired-other-window"},
- {d_rename, "dired-rename-file"},
- {d_undel, "dired-unflag"},
-#endif /* !NO_DIRED */
- {lowerregion, "downcase-region"},
- {lowerword, "downcase-word"},
- {showversion, "emacs-version"},
-#ifndef NO_MACRO
- {finishmacro, "end-kbd-macro"},
-#endif /* !NO_MACRO */
- {gotoeob, "end-of-buffer"},
- {gotoeol, "end-of-line"},
- {enlargewind, "enlarge-window"},
- {NULL, "esc prefix"},
-#ifndef NO_STARTUP
- {evalbuffer, "eval-current-buffer"},
- {evalexpr, "eval-expression"},
-#endif /* !NO_STARTUP */
- {swapmark, "exchange-point-and-mark"},
- {extend, "execute-extended-command"},
- {NULL, "extra prefix 1"},
- {NULL, "extra prefix 2"},
- {NULL, "extra prefix 3"},
- {NULL, "extra prefix 4"},
- {NULL, "extra prefix 5"},
- {fillpara, "fill-paragraph"},
- {filevisit, "find-file"},
- {poptofile, "find-file-other-window"},
- {forwchar, "forward-char"},
- {gotoeop, "forward-paragraph"},
- {forwword, "forward-word"},
- {bindtokey, "global-set-key"},
- {unbindtokey, "global-unset-key"},
- {gotoline, "goto-line"},
-#ifndef NO_HELP
- {NULL, "help"},
- {help_help, "help-help"},
-#endif /* !NO_HELP */
- {insert, "insert"},
- {bufferinsert, "insert-buffer"},
- {fileinsert, "insert-file"},
- {fillword, "insert-with-wrap"},
- {backisearch, "isearch-backward"},
- {forwisearch, "isearch-forward"},
- {justone, "just-one-space"},
- {ctrlg, "keyboard-quit"},
- {killbuffer, "kill-buffer"},
- {killline, "kill-line"},
- {killpara, "kill-paragraph"},
- {killregion, "kill-region"},
- {delfword, "kill-word"},
- {listbuffers, "list-buffers"},
-#ifndef NO_STARTUP
- {evalfile, "load"},
-#endif /* !NO_STARTUP */
- {localbind, "local-set-key"},
- {localunbind, "local-unset-key"},
-#ifndef NO_BACKUP
- {makebkfile, "make-backup-files"},
-#endif /* !NO_BACKUP */
-#ifdef DO_METAKEY
- {do_meta, "meta-key-mode"}, /* better name, anyone? */
-#endif /* DO_METAKEY */
- {negative_argument, "negative-argument"},
- {newline, "newline"},
- {indent, "newline-and-indent"},
- {forwline, "next-line"},
-#ifdef NOTAB
- {notabmode, "no-tab-mode"},
-#endif /* NOTAB */
- {notmodified, "not-modified"},
- {openline, "open-line"},
- {nextwind, "other-window"},
- {overwrite, "overwrite-mode"},
-#ifdef PREFIXREGION
- {prefixregion, "prefix-region"},
-#endif /* PREFIXREGION */
- {backline, "previous-line"},
-#ifdef GOSMACS
- {prevwind, "previous-window"},
-#endif /* GOSEMACS */
- {spawncli, "push-shell"},
-#ifndef NO_DIR
- {showcwdir, "pwd"},
-#endif /* !NO_DIR */
- {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"},
- {refresh, "redraw-display"},
- {filesave, "save-buffer"},
- {quit, "save-buffers-kill-emacs"},
- {savebuffers, "save-some-buffers"},
- {backpage, "scroll-down"},
-#ifdef GOSMACS
- {back1page, "scroll-one-line-down"},
- {forw1page, "scroll-one-line-up"},
-#endif /* GOSMACS */
- {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"},
-#ifdef PREFIXREGION
- {setprefix, "set-prefix-string"},
-#endif /* PREFIXREGION */
- {shrinkwind, "shrink-window"},
-#ifdef NOTAB
- {space_to_tabstop, "space-to-tabstop"},
-#endif /* NOTAB */
- {splitwind, "split-window-vertically"},
-#ifndef NO_MACRO
- {definemacro, "start-kbd-macro"},
-#endif /* !NO_MACRO */
- {spawncli, "suspend-emacs"},
- {usebuffer, "switch-to-buffer"},
- {poptobuffer, "switch-to-buffer-other-window"},
- {twiddle, "transpose-chars"},
- {universal_argument, "universal-argument"},
- {upperregion, "upcase-region"},
- {upperword, "upcase-word"},
- {showcpos, "what-cursor-position"},
- {filewrite, "write-file"},
- {yank, "yank"},
-};
-
-#define NFUNCT (sizeof(functnames)/sizeof(FUNCTNAMES))
-
-/*
- * The general-purpose version of ROUND2 blows osk C (2.0) out of the water.
- * (reboot required) If you need to build a version of mg with less than 32
- * or more than 511 functions, something better must be done.
- * The version that should work, but doesn't is:
- * #define ROUND2(x) (1+((x>>1)|(x>>2)|(x>>3)|(x>>4)|(x>>5)|(x>>6)|(x>>7)|\
- * (x>>8)|(x>>9)|(x>>10)|(x>>11)|(x>>12)|(x>>13)|(x>>14)|(x>>15)))
- */
-#define ROUND2(x) (x<128?(x<64?32:64):(x<256?128:256))
-
-static int
-name_fent(fname, flag)
- char *fname;
- int flag;
-{
- int try, notit;
- int x = ROUND2(NFUNCT);
- int base = 0;
-
- do {
- /* + can be used instead of | here if more efficent. */
- if ((try = base | x) < NFUNCT) {
- if ((notit = strcmp(fname, functnames[try].n_name))
- >= 0) {
- if (!notit)
- return try;
- base = try;
- }
- }
- /* try 0 once if needed */
- } while ((x >>= 1) || (try == 1 && base == 0));
- return flag ? base : -1;
-}
-
-/*
- * Translate from function name to function pointer, using binary search.
- */
-
-PF
-name_function(fname)
- char *fname;
-{
- int i;
- if ((i = name_fent(fname, FALSE)) >= 0)
- return functnames[i].n_funct;
- return (PF)NULL;
-}
-
-/*
- * list possible function name completions.
- */
-LIST *
-complete_function_list(fname, c)
- char *fname;
- int c;
-{
- int i, j, k, l;
- LIST *current, *last;
-
- i = name_fent(fname, TRUE);
- for (j = 0; (l = fname[j]) && functnames[i].n_name[j] == l; j++);
- if (fname[j] != '\0') {
- if (++i >= NFUNCT)
- /* no match */
- return NULL;
- for (j = 0; (l = fname[j]) && functnames[i].n_name[j] == l;
- j++);
- if (fname[j] != '\0')
- /* no match */
- return NULL;
- }
- /*
- * if(c==CCHR('M') && functnames[i].n_name[j]=='\0') return -1;
- */
- /* find last match */
- for (k = i + 1; k < NFUNCT; k++) {
- for (l = 0; functnames[k].n_name[l] == fname[l]; l++);
- if (l < j)
- break;
- }
- k--;
- last = NULL;
- for (; k >= i; k--) {
- current = (LIST *)malloc(sizeof(LIST));
- current->l_next = last;
- current->l_name = functnames[k].n_name;
- last = current;
- }
- return (last);
-}
-
-/*
- * translate from function pointer to function name.
- */
-char *
-function_name(fpoint)
- PF fpoint;
-{
- const FUNCTNAMES *fnp = &functnames[0];
-
- if (fpoint == NULL)
- /* ambiguous */
- return NULL;
- do {
- if (fnp->n_funct == fpoint)
- return fnp->n_name;
- } while (++fnp < &functnames[NFUNCT]);
- return NULL;
-}
diff --git a/usr.bin/mg/main.c b/usr.bin/mg/main.c
index e218b286548..491f6b1d5e6 100644
--- a/usr.bin/mg/main.c
+++ b/usr.bin/mg/main.c
@@ -1,10 +1,11 @@
-/* $OpenBSD: main.c,v 1.10 2001/05/24 03:05:24 mickey Exp $ */
+/* $OpenBSD: main.c,v 1.11 2001/05/24 09:47:34 art Exp $ */
/*
* Mainline.
*/
#include "def.h"
+#include "funmap.h"
#ifndef NO_MACRO
#include "macro.h"
@@ -36,6 +37,7 @@ main(argc, argv)
dirinit(); /* Get current directory. */
#endif /* !NO_DIR */
edinit(); /* Buffers, windows. */
+ funmap_init(); /* Functions. */
ttykeymapinit(); /* Symbols, bindings. */
/*