summaryrefslogtreecommitdiffstats
path: root/examples/rlkeymaps.c
blob: fef77b35ab90693c193003c128638f69ff1659fa (plain)
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
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>

#if defined (READLINE_LIBRARY)
#  include "readline.h"
#  include "history.h"
#else
#  include <readline/readline.h>
#  include <readline/history.h>
#endif

int
main (int c, char **v)
{
  Keymap nmap, emacsmap, newemacs;
  int r, errs;

  errs = 0;
  nmap = rl_make_keymap ();

  r = rl_set_keymap_name ("emacs", nmap);
  if (r >= 0)
    {
      fprintf (stderr, "rlkeymaps: error: able to rename `emacs' keymap\n");
      errs++;
    }

  emacsmap = rl_get_keymap_by_name ("emacs");
  r = rl_set_keymap_name ("newemacs", emacsmap);
  if (r >= 0)
    {
      fprintf (stderr, "rlkeymaps: error: able to set new name for emacs keymap\n");
      errs++;
    }

  r = rl_set_keymap_name ("newemacs", nmap);
  if (r < 0)
    {
      fprintf (stderr, "rlkeymaps: error: newemacs: could not set keymap name\n");
      errs++;
    }

  newemacs = rl_copy_keymap (emacsmap);
  r = rl_set_keymap_name ("newemacs", newemacs);
  if (r < 0)
    {
      fprintf (stderr, "rlkeymaps: error: newemacs: could not set `newemacs' keymap to new map\n");
      errs++;
    }

  r = rl_set_keymap_name ("emacscopy", newemacs);
  if (r < 0)
    {
      fprintf (stderr, "rlkeymaps: error: emacscopy: could not rename created keymap\n");
      errs++;
    }

  exit (errs);
}